Esempio n. 1
0
        public override bool Update()
        {
            if (!base.Update())
            {
                return(false);
            }

            Transform platform = Positional.GetPlatform(_config.Target, 5.0f);

            if (platform != Positional.GetPlatform(Config.Owner.transform))
            {
                PushMoveState(_config.Target, platform);
                return(true);
            }

            //This is for when the last node in the path isn't actually the target
            //but we still want to move towards it
            MoveToState.MoveTowards(Config.Owner, _config.Target);
            return(true);
        }
Esempio n. 2
0
        public static State GetState(StateConfig config)
        {
            UnityEngine.Profiling.Profiler.BeginSample("Construct state");

            State state = null;

            switch (config.StateType)
            {
            case States.MoveTo:
                Debug.Assert(config is MoveToState.MoveToConfig);
                state = new MoveToState(config as MoveToState.MoveToConfig);
                break;

            case States.Idle:
                Debug.Assert(config is IdleState.IdleConfig);
                state = new IdleState(config as IdleState.IdleConfig);
                break;

            case States.Traverse:
                Debug.Assert(config is TraverseState.TraverseStateConfig);
                state = new TraverseState(config as TraverseState.TraverseStateConfig);
                break;

            case States.PathTo:
                Debug.Assert(config is PathToState.PathToConfig);
                state = new PathToState(config as PathToState.PathToConfig);
                break;

            case States.Attack:
            {
                Debug.Assert(config is AttackState.AttackConfig);
                switch (config.Owner.Config.Faction)
                {
                case CharacterFaction.Circle:
                    state = new DashAttackState(config as AttackState.AttackConfig);
                    break;

                case CharacterFaction.Square:
                    state = new MeleeAttackState(config as AttackState.AttackConfig);
                    break;

                case CharacterFaction.Triangle:
                    state = new RangedAttackState(config as AttackState.AttackConfig);
                    break;

                default:
                    Debug.Assert(false, "Shouldn't have got here");
                    break;
                }
                break;
            }

            case States.Steal:
                Debug.Assert(config is StealState.StealConfig);
                state = new StealState(config as StealState.StealConfig);
                break;

            case States.Justice:
                Debug.Assert(config is ServeJusticeState.JusticeConfig);
                state = new ServeJusticeState(config as ServeJusticeState.JusticeConfig);
                break;

            case States.Flee:
                Debug.Assert(config is FleeState.FleeConfig);
                state = new FleeState(config as FleeState.FleeConfig);
                break;

            case States.Mine:
                Debug.Assert(config is MineCurrencyState.MineCurrencyConfig);
                state = new MineCurrencyState(config as MineCurrencyState.MineCurrencyConfig);
                break;

            case States.Defend:
            case States.INVALID:
            default:
                Debug.LogError("Factory not set up for state type " + config.StateType);
                break;
            }

            UnityEngine.Profiling.Profiler.EndSample();
            return(state);
        }