Exemple #1
0
        public void Init(UnitData data)
        {
            //Debug.Log(data.name + " Init");
            this.data = (UnitData)data.Clone();
            name      = this.data.name;
            if (this.data.isFriendly)
            {
                gameObject.layer = GameDatabase.friendlyLayer;
            }
            else
            {
                gameObject.layer = GameDatabase.enemyLayer;
            }

            deathable.Init();
            animator.runtimeAnimatorController = this.data.controller;

            moveable.Init(this.data);
            moveable.enabled = true;

            if (attackable)
            {
                attackable.enabled = false;
            }
            if (this.data.weapon >= 0)
            {
                switch (GameDatabase.instance.weapons[this.data.weapon].type)
                {
                case ATTACK_TYPE.STOP_BEFORE:
                    attackable = stopBeforeAttackable;
                    break;

                case ATTACK_TYPE.STOP_AFTER:
                    attackable = stopAfterAttackable;
                    break;

                case ATTACK_TYPE.DONT_STOP:
                    attackable = dontStopAttackable;
                    break;
                }
                attackable.Init(this.data);
                attackable.enabled = true;
            }

            DisableTargetables();
            if (this.data.isFriendly)
            {
                targetable = enemyTargetable;
            }
            else
            {
                targetable = friendlyTargetable;
            }
            targetable.enabled = true;

            DisableAutoMoveables();
            switch (this.data.move)
            {
            case MOVE_TYPE.RANDOM:
                autoMoveable = randomMoveable;
                break;

            case MOVE_TYPE.RUSH:
                autoMoveable = rushMoveable;
                break;

            case MOVE_TYPE.REST_RUSH:
                autoMoveable = restRushMoveable;
                break;

            case MOVE_TYPE.FOLLOW:
                autoMoveable = followMoveable;
                break;

            case MOVE_TYPE.BOSS0:
                autoMoveable = boss0Moveable;
                break;

            default:
                autoMoveable = null;
                break;
            }
            if (autoMoveable)
            {
                autoMoveable.Init(this.data);
                autoMoveable.enabled = true;
            }

            hpable.Init(this.data.stat);
            mpable.Init(this.data.stat);
            hpable.enabled = true;
            mpable.enabled = true;

            timeLimitable.enabled = false;
            timeLimitable.Init(this.data.limitTime);

            followable.Init(this.data);

            orderable.Init(data.order);

            effectable.Init();

            if (this.data.effects != null)
            {
                for (int i = 0; i < this.data.effects.Length; i++)
                {
                    effectable.AddEffect(this.data.effects[i]);
                }
            }

            if (this.data.color == Color.clear)
            {
                renderer.color = Color.white;
            }
            else
            {
                renderer.color = this.data.color;
            }
            collider.isTrigger = false;
            collider.enabled   = true;

            tackleable.Init(data);

            //그림자 세팅
            this.shadow.Initialize(this.data.shadowZAngle, this.data.shadowXFlip, this.data.shadowPos);
        }