Exemple #1
0
    public virtual void SetPossessionAs(GameObject newCreature)
    {
        if (_currentPossession)
        {
            //Kill _currentPossession;
            Destroy(_currentPossession);
        }

        _currentPossession = newCreature;
        if (_cc)
        {
            _cc.target = newCreature.transform;
        }

        _aim = newCreature.GetComponent <AIManager>();
        if (_aim)
        {
            _aim.isControllingCreature = false;
            _aim.MyAgent.enabled       = false;
            if (_aim.crownSpawnLocation && CrownPrefab)
            {
                Instantiate(CrownPrefab, _aim.crownSpawnLocation);
            }
        }
        _sm = newCreature.GetComponent <StatesManager>();
        if (_sm)
        {
            _sm.DoTransition(moveState);
            playerMoveState pms = moveState as playerMoveState;
            if (pms && _aim)
            {
                pms.speed = _aim.MyAgent.speed * 2;
            }
        }
    }