Esempio n. 1
0
    protected override void Awake()
    {
        gameObject.AddComponent <PlayerMotion>().model = model;
        base.Awake();
        switch (job)
        {
        case PlayerJob.Swordmaster:
            status = new SwordMasterCharacterState(CharacterName);
            break;

        case PlayerJob.Archer:
            status = new ArcherCharacterState(CharacterName);
            break;

        case PlayerJob.Wizzard:
            status = new WizzardCharacterState(CharacterName);
            break;

        default:
            status = new SwordMasterCharacterState(CharacterName);
            break;
        }
        SetConsumedAttrUpdate();
        PlayerName = CharacterName;
        Instance   = this;
        NavMeshObstacle navObstacle = gameObject.AddComponent <NavMeshObstacle>();

        navObstacle.shape  = NavMeshObstacleShape.Capsule;
        navObstacle.height = GetComponent <CharacterController>().height;
        navObstacle.radius = GetComponent <CharacterController>().radius;
        navObstacle.center = GetComponent <CharacterController>().center;
        Followers          = new List <NPCController>();
    }
    protected override void Awake()
    {
        movementAI = GetComponent <BaseNPCMovementAI>();
        switch (job)
        {
        case NPCJobs.Warrior:
            status = new SwordMasterCharacterState(CharacterName);
            movementAI.IsRanger = false;
            gameObject.AddComponent <AttackAI>();
            break;

        case NPCJobs.Archer:
            status = new ArcherCharacterState(CharacterName);
            movementAI.IsRanger = true;
            gameObject.AddComponent <RangeAttackAI>();
            break;

        case NPCJobs.Mage:
            status = new WizzardCharacterState(CharacterName);
            movementAI.IsRanger = true;
            gameObject.AddComponent <RangeAttackAI>();
            break;

        case NPCJobs.Magician:
            status = new MagicianCharacterState(CharacterName);
            movementAI.IsRanger = true;
            gameObject.AddComponent <RangeAttackAI>();
            break;

        case NPCJobs.Knight:
            status = new KnightCharacterState(CharacterName);
            movementAI.IsRanger = false;
            gameObject.AddComponent <AttackAI>();
            break;

        case NPCJobs.Priest:
            status = new PriestCharacterState(CharacterName);
            movementAI.IsRanger = false;
            gameObject.AddComponent <AttackAI>();
            break;

        case NPCJobs.Monster:
            status = new MonsterCharacterState(CharacterName);
            if (movementAI.IsRanger)
            {
                gameObject.AddComponent <RangeAttackAI>();
            }
            else
            {
                gameObject.AddComponent <AttackAI>();
            }
            break;

        default:
            break;
        }
        movementAI.NPCType = NPCType;
        //gameObject.AddComponent<NPCMotion>().model = model;
        movementAI.SetStatus(status);
        base.Awake();
        MakeBloodBar();

        //eargleEyeImgTransform.GetComponent<MeshRenderer>().materials[0].mainTexture = ResourceLoader.NPC.GetFaceicon(job);

        navAgent                  = gameObject.AddComponent <NavMeshAgent>();
        navAgent.height           = BodyHeight;
        navAgent.radius           = BodyWidth / 2;
        navAgent.baseOffset       = 0.01f;
        navAgent.stoppingDistance = BodyWidth;
        navAgent.autoRepath       = true;
        navAgent.autoBraking      = true;
    }