示例#1
0
    private void Awake()
    {
        character     = GetComponent <Character>();
        healthHandler = GetComponent <HealthHandler>();
        healthHandler.SetMaxHealth(character.maxHealth);

        movementType           = Character.MovementType.MoveToPoint;
        character.movementType = movementType;


        foreach (Transform point in patrolPointsObject.GetComponentInChildren <Transform>())
        {
            patrolPoints.Add(point.position);
        }

        machine             = GetComponentInChildren <StateMachine>();
        character.stateList = new List <State>()
        {
            new State_Idle(character),
            new State_Patrol(character, patrolPoints, patrolPointsObject.transform, roamRadius, patrolType),
            new State_Chase(character),
            new State_Search(character, this, 100f, 10f),
            new State_Attack(character),
            new State_Interact(character),
        };


        character.stateMachine            = machine;
        character.stateMachine.startState = character.stateList[0];
        //machine.SetState(stateList[1]);
    }
示例#2
0
    void ClickOrWASD()
    {
        //Some bug if you change movement type while character is moving. Need to set the state to idle if this is changed in runtime.

        if (clickToMove)
        {
            movementType           = Character.MovementType.MoveToPoint;
            character.movementType = movementType;
        }
        else
        {
            movementType           = Character.MovementType.MoveToward;
            character.movementType = movementType;
        }
        //character.positionOrDirection = FindWhereToGo();
    }