Exemplo n.º 1
0
    void Awake()
    {
        damageReceived = 0;

        movingState   = new MovingState(this);
        rotatingState = new RotatingState(this);
        castingState  = new CastingState(this);
        stunnedState  = new StunnedState(this);
        deadState     = new DeadState(this);

        movingState.AddPauser(castingState);
        movingState.AddPauser(stunnedState);
        movingState.AddBlocker(deadState);

        rotatingState.AddPauser(stunnedState);
        rotatingState.AddBlocker(deadState);

        castingState.AddBlocker(stunnedState);
        castingState.AddBlocker(deadState);

        stunnedState.AddBlocker(deadState);

        actionStates = new List <ActionState>();
        actionStates.Add(movingState);
        actionStates.Add(rotatingState);
        actionStates.Add(castingState);
        actionStates.Add(stunnedState);
        actionStates.Add(deadState);

        if (skills == null)
        {
            skills = new List <Skill>();
        }

        if (perks == null)
        {
            perks = new List <Perk>();
        }

        graphics = gameObject.AddComponent <UnitGraphics>();

        if (activeController == null)
        {
            activeController = gameObject.GetComponent <UnitController>();
        }

        if (unitData == null)
        {
            unitData = new UnitData();
        }
    }