コード例 #1
0
ファイル: UnitCreep.cs プロジェクト: wattson-coder/TD
        protected override void Wandering()
        {
            if (!dead && !stunned && allowWandering)
            {
                //print(unitName + " are Wandering");
                timer += Time.deltaTime;

                if (timer >= timeToNextMove)
                {
                    Vector3 newPos = UnitDefender.RandomNavSphere(transform.position, maxDistance, -1);
                    agent.SetDestination(newPos);
                    timer = 0;
                }
            }
            else
            {
                if (behaviour == Behaviour.NoMoreEnemies)
                {
                    animController.PlayIdleAnimation();
                }
                else
                {
                    animController.PlayRunAnimation();
                }
            }
        }
コード例 #2
0
ファイル: DefenderInspector.cs プロジェクト: wattson-coder/TD
        public override void OnInspectorGUI()
        {
            EditorGUILayout.Space();
            DrawButtons();
            DrawUnitGUI();

            UnitDefender unit = (UnitDefender)target;

            unit.moveSpeed      = EditorGUILayout.IntField("Move Speed:", unit.moveSpeed);
            unit.rotateSpd      = EditorGUILayout.FloatField("Rotation Speed:", unit.rotateSpd);
            unit.allowWandering = EditorGUILayout.Toggle("Allow wandering:", unit.allowWandering);

            if (unit.allowWandering)
            {
                unit.timeToNextMove = EditorGUILayout.FloatField("Time To Next Move:", unit.timeToNextMove);
                unit.maxDistance    = EditorGUILayout.FloatField("Max Distance:", unit.maxDistance);
            }
            if (unit.behaviour == Behaviour.TacticallyMove)
            {
                unit.evasionRange = EditorGUILayout.FloatField("Evasion Range:", unit.evasionRange);
            }
            base.OnInspectorGUI();
        }