Example #1
0
    /// <summary>
    /// We've died, destroy our gameobject
    /// </summary>
    public void Die()
    {
        _aiMood = AiMood.Dead;
        AgentActions actions = gameObject.GetComponent <AgentActions>();

        actions.DropAllItems();
        Destroy(gameObject);
    }
    System.Collections.IEnumerator WaitForRevive()
    {
        CurrentHitPoints = MaxHitPoints;

        yield return(new WaitForSeconds(3));

        this.gameObject.transform.position  = this.gameObject.GetComponent <AI>().startPostion();
        this.gameObject.transform.position += new Vector3(0, 1.0f, 0);
        gameObject.GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = true;
        _aiMood = AiMood.Idle;
    }
 void Update()
 {
     // TODO: Maybe remove this
     // Show the sadface when hitpoints are low
     if (CurrentHitPoints < MaxHitPoints / 2)
     {
         _aiMood = AiMood.Losing;
     }
     else
     {
         _aiMood = AiMood.Idle;
     }
 }
Example #4
0
    /// <summary>
    /// We've died, destroy our gameobject
    /// </summary>
    public void Die()
    {
        _isAlive = false;
        _aiMood  = AiMood.Dead;

        Dictionary <string, GameObject> inventory = gameObject.GetComponentInChildren <InventoryController>().Items;
        AgentActions actions = gameObject.GetComponent <AgentActions>();

        foreach (var item in inventory)
        {
            actions.DropItem(item.Value);
        }

        Destroy(gameObject);
    }
    /// <summary>
    /// We've died, destroy our gameobject
    /// </summary>
    public void Die()
    {
        CurrentHitPoints = MaxHitPoints;
        _aiMood          = AiMood.Dead;
        AgentActions actions = gameObject.GetComponent <AgentActions>();

        actions.DropAllItems();
        //Destroy(gameObject);
        gameObject.GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = false;
        //gameObject.GetComponent<AI>().Dead();
        if (FriendlyTeam == Teams.BlueTeam)
        {
            transform.position = new Vector3(100.0f, 100.0f, 100.0f);
        }
        if (FriendlyTeam == Teams.RedTeam)
        {
            transform.position = new Vector3(-100.0f, 100.0f, 100.0f);
        }

        StartCoroutine(WaitForRevive());
    }