Exemple #1
0
 void EndEpisode()
 {
     GameObject[] Remained = inspector.getCurrentUnits();
     foreach (GameObject unit in Remained)
     {
         if (inspector.setScriptsFrom(unit))
         {
             if (inspector.getScriptType() == "Unit")
             {
                 inspector.removeFrom(unit);
                 Destroy(unit);
             }
             else if (inspector.getScriptType() == "AgentScript")
             {
                 Debug.LogWarning("Agent Remained after episode ends");
             }
         }
     }
     sys.battleStarted = false;
     System.Array.Resize(ref sys.knightUnits, 0);
     System.Array.Resize(ref sys.enemyUnits, 0);
     foreach (GameObject unit in inspector.getInstantiatedUnits())
     {
         Destroy(unit);
     }
     foreach (GameObject corpe in GameObject.FindGameObjectsWithTag("Ragdoll"))
     {
         corpe.GetComponent <DeleteParticles>().DestroyMe();
     }
 }
    public void die()
    {
        //create the ragdoll at the current position
        if (!dead)
        {
            Instantiate(ragdoll, transform.position, transform.rotation);
        }

        dead = true;
        inspector.removeFrom(this.gameObject);
        Destroy(gameObject);
        //wait a moment and destroy the original unit
        return;
    }
 public void innerDie()
 {
     try {
         if (!dead)
         {
             Instantiate(ragdoll, transform.position, transform.rotation);
         }
     } catch {
         Debug.LogWarning("Error on placing deadbody. You probably unsigned the ragdoll from editor manually.");
     }
     dead = true;
     //Destroy(DamagedParticle.gameObject);
     agent.isStopped = true;
     agent.enabled   = false;
     gameObject.transform.position = new Vector3(-999, -999, -999);
     RequestDecision();
     inspector.removeFrom(this.gameObject);
 }