当前位置: 首页>>代码示例>>C#>>正文


C# Ship.GetMyFleet方法代码示例

本文整理汇总了C#中Ship.GetMyFleet方法的典型用法代码示例。如果您正苦于以下问题:C# Ship.GetMyFleet方法的具体用法?C# Ship.GetMyFleet怎么用?C# Ship.GetMyFleet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ship的用法示例。


在下文中一共展示了Ship.GetMyFleet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetTargetShip

    public void SetTargetShip(Ship inship)
    {
        if (inship == null)
            return;

        target = inship.gameObject.transform;
        targetFleet = inship.GetMyFleet();
        photonView.RPC("SetTargetShipRPC", PhotonTargets.Others, inship.photonView.viewID);
    }
开发者ID:KenReaGameDev,项目名称:Apparent-Horizon,代码行数:9,代码来源:Ship.cs

示例2: DetermineBehavior

    public void DetermineBehavior(Ship leader, Ship subject)
    {
        if (subject.behavior == null)
        {
            //Debug.LogWarning("Behavior for " + subject.name + " is null.");
            subject.SetBehavior(new DoNothing(subject));
        }
        ////Debug.Log("Determining Behavior for " + subject.name + " fleet leader: " + subject.isFleetLeader);

        // Check if current should stay the same.
        if (subject.GetBehavior().KeepBehaviorCheck((AiShip)leader, (AiShip)subject))
            return;

        ////Debug.Log("Passed initial check");
        subject.GetBehavior().CallSwitch();
        //subject.SetBehavior(new DoNothing(subject));

        if (leader.GetBehavior() is Search && !subject.isFleetLeader)
        {
            Debug.Log("Search Follow");
            subject.SetBehavior(new SearchFollow(subject));
            Debug.Log("Setting Behavior Name");
            subject.behaviorName = subject.GetBehavior().ToString();
            return;
        }

        bool isHealthy = false;
        bool hasTarget = false;
        bool canSearch = false;
        bool canMultiTarget = false;
        bool hasAggressors = false;

        double health = ((subject.GetAttributes().structureHealth + subject.GetAttributes().armorHealth + subject.GetAttributes().shieldHealth) * 100) / subject.maxHealth;
        if (health > 51)
            isHealthy = true;

        // This is for MultiSoloEngage possiblity. Determine the range later.
        /*
        if (subject.type is Between certain Range)
            canMultiTarget = true;
        */

        if (subject.GetTarget() != null)
            hasTarget = true;

        if (subject.Aggressors.Count > 0)
            hasAggressors = true;

        if (subject.isFleetLeader == true && !hasAggressors && isHealthy && !hasTarget)
            canSearch = true;

        // Healthy Behaviors
        if (isHealthy)
        {
            if (leader.GetBehavior() is TeamEngage && leader.target != null)
            {
                subject.SetBehavior(new TeamEngage(subject));
                subject.behaviorName = subject.GetBehavior().ToString();
                return;
            }

            if (leader.targetFleet != null)
                counterThreat = RealThreatDeterminer(subject.GetMyFleet(), leader.targetFleet);
            else
                goto SkipHealthy;

            // If target is threatening, Fight with team.
            if (hasTarget && counterThreat < 20 && subject.isFleetLeader)
            {
                ////Debug.Log("Team Engaging");
                subject.SetBehavior(new TeamEngage(subject));// Team Engage
                subject.behaviorName = subject.GetBehavior().ToString();
                return;
            }

            // Solo Engage
            if (counterThreat >= 20 )
            {
                ////Debug.Log("Solo Engaging " + subject.gameObject.name);
                int count = 0;
                int threatLevel = subject.GetAttributes().threatLevel;
                float threatHigh = threatLevel * 2;
                float threatLow = -5;

                // Attacks any players in fleet first.
                int pcount = leader.targetFleet.pFleet.Count;
                if (leader.targetFleet.pFleet.Count > 0)
                {
                    subject.SetTargetShip(leader.targetFleet.pFleet[rnd.Next(0, pcount - 1)]);
                    subject.SetBehavior(new SoloEngage(subject));
                    subject.behaviorName = subject.GetBehavior().ToString();
                    return;
                }

                count = 0;

                int acount = leader.targetFleet.fleet.Count;
                if (acount > 0)
                {
                    subject.SetTargetShip(leader.targetFleet.fleet[rnd.Next(0, acount - 1)]);
//.........这里部分代码省略.........
开发者ID:KenReaGameDev,项目名称:Apparent-Horizon,代码行数:101,代码来源:BehaviorDeterminerAiShip.cs


注:本文中的Ship.GetMyFleet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。