Ejemplo n.º 1
0
    void Awake()
    {
        homeSet         = false;
        survivorFood    = 0;
        survivorWater   = 0;
        survivorBandage = 0;
        survivorScrap   = 0;

        survivorHealth    = 100;
        survivorHunger    = 90;
        survivorThirst    = 90;
        survivorTiredness = 90;

        wayPointsList = new List <Vector3>();

        collectState  = new CollectState(this);
        buildState    = new BuildState(this);
        nourrishState = new NourrishState(this);
        fightState    = new FightState(this);
        repairState   = new RepairState(this);
        sleepState    = new SleepState(this);
        homeState     = new HomeState(this);
        healState     = new HealState(this);
        currentMap    = GameObject.Find("Map");
    }
Ejemplo n.º 2
0
    private void ConstructFSM()
    {
        //Get the list of points
        pointList = GameObject.FindGameObjectsWithTag("WandarPoint");

        Transform[] waypoints = new Transform[pointList.Length];
        int         i         = 0;

        foreach (GameObject obj in pointList)
        {
            waypoints[i] = obj.transform;
            i++;
        }

        PatrolState patrol = new PatrolState(waypoints, this);

        patrol.AddTransition(Transition.SawPlayer, FSMStateID.Chasing);
        patrol.AddTransition(Transition.LowHealth, FSMStateID.Healing);
        patrol.AddTransition(Transition.NoHealth, FSMStateID.Dead);
        patrol.AddTransition(Transition.HasBoredom, FSMStateID.Bored);

        ChaseState chase = new ChaseState(waypoints, this);

        chase.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling);
        chase.AddTransition(Transition.ReachPlayer, FSMStateID.Attacking);
        chase.AddTransition(Transition.LowHealth, FSMStateID.Healing);
        chase.AddTransition(Transition.NoHealth, FSMStateID.Dead);

        AttackState attack = new AttackState(waypoints, this);

        attack.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling);
        attack.AddTransition(Transition.SawPlayer, FSMStateID.Chasing);
        attack.AddTransition(Transition.LowHealth, FSMStateID.Healing);
        attack.AddTransition(Transition.NoHealth, FSMStateID.Dead);

        DeadState dead = new DeadState();

        dead.AddTransition(Transition.NoHealth, FSMStateID.Dead);

        HealState heal = new HealState(waypoints, this);

        heal.AddTransition(Transition.SawPlayer, FSMStateID.Chasing);
        heal.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling);
        heal.AddTransition(Transition.NoHealth, FSMStateID.Dead);

        BoredState bored = new BoredState(waypoints, this);

        bored.AddTransition(Transition.SawPlayer, FSMStateID.Chasing);
        bored.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling);
        bored.AddTransition(Transition.LowHealth, FSMStateID.Healing);
        bored.AddTransition(Transition.NoHealth, FSMStateID.Dead);

        AddFSMState(patrol);
        AddFSMState(chase);
        AddFSMState(attack);
        AddFSMState(dead);
        AddFSMState(heal);
        AddFSMState(bored);
    }
Ejemplo n.º 3
0
    private static HealState instance; //Static instance of the state

    private HealState()                //Constructor for the state
    {
        if (instance != null)          //If we already have an instance of this state, we don't need another one
        {
            return;
        }
        instance = this;
    }
Ejemplo n.º 4
0
    private static HealState _instance; //only declared once

    private HealState()                 //set instance to itself
    {
        if (_instance != null)
        {
            return;
        }

        _instance = this;
    }
Ejemplo n.º 5
0
 public override void Heal()
 {
     base.Heal();
     if (details.CheckBattery(details.healCost))
     {
         currentState = new HealState(details);
         currentState.Heal();
     }
 }
Ejemplo n.º 6
0
    void Update()
    {
        //transform.LookAt(hero.transform);
        if(Input.GetMouseButtonDown(0) || (Input.touchCount == 1))
        {
            if(HP > HPLossStep)
            {
                HP -= HPLossStep;
                healState = HealState.HST_USING;
            }
            else
            {
                HP = 0;
                healState = HealState.HST_USED;
            }
        }

        if(Input.GetMouseButtonDown(1) || (Input.touchCount == 4))
        {
            HP = 100;
            healState = HealState.HST_RECOVERD;
        }
    }
Ejemplo n.º 7
0
    void Start()
    {
        hero = GameObject.FindGameObjectWithTag("Player");
        camera = Camera.main;

        float size_y = collider.bounds.size.y;
        float scal_y = transform.localScale.y;
        npcHeight = (size_y *scal_y) ;

        healState = HealState.HST_START;
    }