Esempio n. 1
0
        public override bool ShouldRunState(AgentController owner, out StateConfig config)
        {
            if (!owner.IsInState <StealState>(false) && owner.GetAbsoluteDesireValue(DesireType.Money) > _moneyDesireThreshold)
            {
                Inventory[] inventories = GameObject.FindObjectsOfType <Inventory>();
                Inventory   toSteal     = inventories.FirstOrDefault(inventory => inventory.OnGround && inventory.Owner != owner && IsInventoryUnattended(inventory, owner));
                if (toSteal != null)
                {
                    config = new StealConfig(toSteal, owner);
                    return(true);
                }
            }

            config = null;
            return(false);
        }
Esempio n. 2
0
        public State(StateConfig config)
        {
            Debug.Assert(config != null);

            Config = config;
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public static bool ShouldEnterState(AgentController owner, SpecialistStates state, out StateConfig config)
        {
            Debug.Assert(state != SpecialistStates.INVALID);
            int idx = Array.FindIndex((SpecialistStates[])Enum.GetValues(typeof(SpecialistStates)), x => x == state) - 1;             //-1 to account for SpecialistStates.INVALID

            return(_referenceSpecialistStates[idx].ShouldRunState(owner, out config));
        }
Esempio n. 5
0
 public override bool ShouldRunState(AgentController owner, out StateConfig config)
 {
     config = null;
     return(false);
 }