コード例 #1
0
ファイル: MasterNergAI.cs プロジェクト: Absidion/Irkalla
        protected override SelectorNode CreateBehaviour()
        {
            //create the dig nodes
            CanDigNode               canDigNode         = new CanDigNode(this);
            HealthLessThanNode       healthCheckNode    = new HealthLessThanNode(this, 0.6f);
            AnimatorNode             digAnimationNode   = new AnimatorNode(this, m_AnimatorRef, "IsDigging", ref m_DigAnimationLink);
            ToggleParticleSystemNode toggleParticleNode = new ToggleParticleSystemNode(this, DigParticleSystem);

            DelegateNode.Delegate toggleTriggerFunc = SetColliderTrigger;
            DelegateNode          toggleTriggerNode = new DelegateNode(this, toggleTriggerFunc, true);

            DelegateNode.Delegate toggleColliderFunc = ToggleCollider;
            DelegateNode          toggleColliderNode = new DelegateNode(this, toggleColliderFunc);

            ToggleNavMeshAgentNode toggleAgentNode = new ToggleNavMeshAgentNode(this);
            DelayNode delayNode = new DelayNode(this, 2.0f);
            //TODO: COMMENT THIS SECTION AND ADD STRING
            PlaySoundNode digSFX       = new PlaySoundNode(this, "NergDig");
            LerpNode      lerpDownNode = new LerpNode(this, Vector3.down, 1.0f, 2.0f, 10.0f);

            DelegateNode.Delegate rotateFunc = RotateVertical;
            DelegateNode          rotateNode = new DelegateNode(this, rotateFunc);

            TeleportToTargetOffsetNode teleportNode     = new TeleportToTargetOffsetNode(this, new Vector3(0.0f, -5.0f, 0.0f));
            LerpToTargetNode           lerpToTargetNode = new LerpToTargetNode(this, 0.5f, 1.0f, 10.0f);
            AnimatorNode        biteAnimationNode       = new AnimatorNode(this, m_AnimatorRef, "IsBiting", ref m_BiteAnimationLink);
            RunUntillTargetNull targetNullNode          = new RunUntillTargetNull(this);

            //create the dig sequence
            SequenceNode digSequence = new SequenceNode(this, "DigSequence",
                                                        healthCheckNode,
                                                        canDigNode,
                                                        toggleParticleNode,
                                                        toggleTriggerNode,
                                                        toggleColliderNode,
                                                        toggleAgentNode,
                                                        delayNode,
                                                        digSFX,
                                                        lerpDownNode,
                                                        toggleParticleNode,
                                                        rotateNode,
                                                        teleportNode,
                                                        toggleColliderNode,
                                                        toggleParticleNode,
                                                        lerpToTargetNode,
                                                        digSFX,
                                                        delayNode,
                                                        toggleParticleNode,
                                                        targetNullNode
                                                        );

            //create the targeting nodes
            TargetingSightNode     sightNode  = new TargetingSightNode(this, 1);
            TargetingLowHealthNode lowHealth  = new TargetingLowHealthNode(this, 3);
            CalculateTargetNode    calcTarget = new CalculateTargetNode(this);

            //assign the targeting sequence
            SequenceNode targetingSequ = new SequenceNode(this, "TargetingSequence", sightNode, lowHealth, calcTarget);

            //create the spit nodes
            CooldownNode spitCooldownNode = new CooldownNode(this, 1.0f);
            //AnimatorNode spitAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsSpitting", ref m_SpitAnimationLink);
            ShootProjectileNode projectileNode = new ShootProjectileNode(this, 1, ProjectilePrefab, ProjectileSpawnLoc, "MasterNergProjectile", 10);
            //SFX for the sound of the nerg spitting
            PlaySoundNode spitSound = new PlaySoundNode(this, "NergSpit");


            //create the movement nodes
            CooldownNode movementCooldownNode = new CooldownNode(this, 3.0f);
            //BackAwayNode backAwayNode = new BackAwayNode(this, false, 1.0f);
            SideStepNode             sideStepNode        = new SideStepNode(this, false, 2.0f);
            PredictiveAvoidanceNode  predictMovementNode = new PredictiveAvoidanceNode(this, false, true, 2.0f, 5.0f);
            MovementOptionRandomNode movementNodes       = new MovementOptionRandomNode(this, sideStepNode, predictMovementNode);

            //SFX for the sound of the nerg moving backward
            //TODO: COMMENT THIS SECTION AND ADD STRING
            //PlaySoundNode crawlingSFX = new PlaySoundNode(this,);

            //create the spit sequence
            SequenceNode spitSequence = new SequenceNode(this, "SpitSequence", spitCooldownNode, projectileNode, spitSound, movementCooldownNode, movementNodes /*, crawlingSFX*/);

            //assign the attack selector
            SelectorNode attackSelector = new SelectorNode(this, "AttackSelector", digSequence, spitSequence);

            //create the attack sequence
            SequenceNode attackSequence = new SequenceNode(this, "AttackTargetSequence", targetingSequ, attackSelector);

            //create utility selector
            SelectorNode utilitySelector = new SelectorNode(this, "UtilitySelector", attackSequence);

            return(utilitySelector);
        }
コード例 #2
0
        protected override SelectorNode CreateBehaviour()
        {
            //Create melee attack nodes

            //Create ground slam nodes
            CooldownNode   groundSlamCooldownNode       = new CooldownNode(this, GroundSlamCooldownTime);
            AnimatorNode   groundSlamStartAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsGroundSlamStarting", ref m_GroundSlamStartLink);
            GroundSlamNode groundSlamNode = new GroundSlamNode(this, FallingRockPrefab, PunchHitBox.transform);

            //TODO: COMMENT THIS SECTION AND ADD STRING
            PlaySoundNode slamSFX = new PlaySoundNode(this, "GolemGroundSlamImpact");
            AnimatorNode  groundSlamRecoveryAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsGroundSlamRecovering", ref m_GroundSlamRecoveryLink);

            ToggleParticleSystemNode toggleGroundSlamPartclesNode = new ToggleParticleSystemNode(this, SlamParticleSystem);

            //Create ground slam sequence
            SequenceNode groundSlamSequence = new SequenceNode(this, "GroundSlamSequence", groundSlamCooldownNode, groundSlamStartAnimationNode, groundSlamNode, toggleGroundSlamPartclesNode, slamSFX, groundSlamRecoveryAnimationNode);

            //Create punch nodes
            CheckDistanceToTargetNode punchDistanceNode = new CheckDistanceToTargetNode(this, 5.0f);

            ToggleMeleeColliderNode togglePunchNode = new ToggleMeleeColliderNode(this, PunchHitBox, 15);

            LookAtTargetNode lookAtTargetNode   = new LookAtTargetNode(this);
            AnimatorNode     punchAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsPunching", ref m_PunchLink);
            //TODO: COMMENT THIS SECTION AND ADD STRING
            PlaySoundNode punchSFX = new PlaySoundNode(this, "GolemPunchImpact");
            //Create punch sequence
            SequenceNode punchSequence = new SequenceNode(this, "PunchSequence", punchDistanceNode, togglePunchNode, lookAtTargetNode, punchSFX, punchAnimationNode, togglePunchNode);

            //Create melee attack selector in order: GroundSlam, Punch
            SelectorNode meleeAttackSelector = new SelectorNode(this, "MeleeAttackSelector");

            meleeAttackSelector.AddChildren(groundSlamSequence, punchSequence);

            //Create ranged attack nodes

            //Create rock throw nodes
            CooldownNode rockThrowCooldownNode       = new CooldownNode(this, 10.0f);
            AnimatorNode rockThrowStartAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsRockThrowStarting", ref m_RockThrowStartLink);
            //TODO: COMMENT THIS SECTION AND ADD STRING
            PlaySoundNode rockThrowSFX = new PlaySoundNode(this, "GolemRockThrow");

            DelegateNode.Delegate setRockMeshFunc     = SetRockMesh;
            DelegateNode          setRockMeshTrueNode = new DelegateNode(this, setRockMeshFunc, true);

            AnimatorNode  rockThrowingAnimationNode      = new AnimatorNode(this, m_AnimatorRef, "IsRockThrowing", ref m_RockThrowingLink);
            DelegateNode  setRockMeshFalseNode           = new DelegateNode(this, setRockMeshFunc, false);
            RockThrowNode rockThrowNode                  = new RockThrowNode(this, RockThrowPrefab, FireLocation, RockThrowDamage);
            AnimatorNode  rockThrowRecoveryAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsRockThrowRecovering", ref m_RockThrowRecoveryLink);

            //Create rock throw sequence
            SequenceNode rockThrowSequence = new SequenceNode(this, "RockThrowSequence", rockThrowCooldownNode,
                                                              rockThrowStartAnimationNode,
                                                              setRockMeshTrueNode,
                                                              rockThrowingAnimationNode,
                                                              setRockMeshFalseNode,
                                                              rockThrowNode,
                                                              rockThrowSFX,
                                                              rockThrowRecoveryAnimationNode
                                                              );

            //Create ground spike nodes
            CooldownNode     groundSpikesCooldownNode       = new CooldownNode(this, 10.0f);
            AnimatorNode     groundSpikesStartAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsGroundSpikeStarting", ref m_GroundSpikesStartLink);
            GroundSpikesNode groundSpikesNode = new GroundSpikesNode(this, SpikePrefab, SpikesMovementTime);
            AnimatorNode     groundSpikesRecoveryAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsGroundSpikesRecovering", ref m_GroundSpikesRecoveryLink);

            //Create ground spike sequence
            SequenceNode groundSpikesSequence = new SequenceNode(this, "GroundSpikesSequence", groundSpikesCooldownNode, groundSpikesStartAnimationNode, groundSpikesNode, groundSpikesRecoveryAnimationNode);

            //Create ranged attack selector in order: RockThrow, GroundSpikes
            SelectorNode rangedAttackSelector = new SelectorNode(this, "RangedAttackSelector");

            rangedAttackSelector.AddChildren(rockThrowSequence, groundSpikesSequence);

            //Create targeting nodes
            TargetingAfflicted         targetingAfflictedNode     = new TargetingAfflicted(this, 8, Status.Stun);
            TargetingDistanceNode      targetingDistanceNode      = new TargetingDistanceNode(this, 1);
            TargetingHighHealthNode    targetingHighHealthNode    = new TargetingHighHealthNode(this, 1);
            TargetingHighestDamageNode targetingHighestDamageNode = new TargetingHighestDamageNode(this, 1);
            TargetingCharacterType     targetingCharacterType     = new TargetingCharacterType(this, 1, WeaponType.RANGED);
            CalculateTargetNode        calculateTargetNode        = new CalculateTargetNode(this);

            //Create the targeting sequence and attach nodes
            SequenceNode targetingSequence = new SequenceNode(this, "TargetingSequence");

            targetingSequence.AddChildren(targetingAfflictedNode,
                                          targetingDistanceNode,
                                          targetingHighHealthNode,
                                          targetingHighestDamageNode,
                                          targetingCharacterType,
                                          calculateTargetNode);

            //Create approach node
            ApproachNode approachNode = new ApproachNode(this);

            //Create Abilities/Melee/Ranged/Approach Selector
            SelectorNode actionSelector = new SelectorNode(this, "ActionSelector");

            actionSelector.AddChildren(meleeAttackSelector, rangedAttackSelector, approachNode);

            //Create Target->Action sequence
            SequenceNode getTargetAndUseAbilitySequence = new SequenceNode(this, "GetTargetAndUseAbilitySequence");

            getTargetAndUseAbilitySequence.AddChildren(targetingSequence, actionSelector);

            //Create the utility selector with the previous sequence and approach node
            SelectorNode utilitySelector = new SelectorNode(this, "UtilitySelector");

            utilitySelector.AddChildren(getTargetAndUseAbilitySequence);

            return(utilitySelector);
        }