Beispiel #1
0
    public EnemyRandomWalk(StateID stateID, NPCBreadcrumb enemyReference)
    {
        this.stateID = stateID;
        this.enemyReference = enemyReference;

        NPCBreadcrumb.FoundPlayer += FoundPlayer;
    }
 public EnemyBreadcrumbWalk(StateID stateID, NPCBreadcrumb enemyReference)
 {
     this.stateID = stateID;
     this.enemyReference = enemyReference;
 }
Beispiel #3
0
 /// <summary>
 /// Destroys the breadcrumb.
 /// </summary>
 /// <param name="enemy"></param>
 public void DestroyBreadcrumb(NPCBreadcrumb enemy)
 {
     this.DestroyBreadcrumb();
 }
 /// <summary>
 /// Stops the spawning.
 /// </summary>
 protected void StopSpawn(NPCBreadcrumb enemy)
 {
     stopSpawning = true;
 }
Beispiel #5
0
 /// <summary>
 /// Sets the player found settings.
 /// </summary>
 protected void FoundPlayer(NPCBreadcrumb enemy)
 {
     playerFound = true;
 }
Beispiel #6
0
 /// <summary>
 /// Sets the player found variables.
 /// </summary>
 protected void PlayerFound(NPCBreadcrumb enemy)
 {
     this.playerWasFound = true;
 }
Beispiel #7
0
    /// <summary>
    /// Writes into the xml file.
    /// </summary>
    /// <param name="time"></param>
    /// <param name="enemy"></param>
    /// <param name="player"></param>
    public void WriteData(TimeUtil time, NPCBreadcrumb enemy, GameObject player)
    {
        if (File.Exists(filePath))
        {
            XmlDocument document = new XmlDocument();
            document.Load(filePath);

            XmlElement root = document.DocumentElement;

            XmlElement entry = document.CreateElement("entry");
            root.AppendChild(entry);

                XmlElement timeNode = document.CreateElement("time");
                entry.AppendChild(timeNode);

                    XmlElement hour = document.CreateElement("minute");
                    hour.InnerText = time.Minute.ToString();
                    timeNode.AppendChild(hour);

                    XmlElement minute = document.CreateElement("second");
                    minute.InnerText = time.Second.ToString();
                    timeNode.AppendChild(minute);

                    XmlElement second = document.CreateElement("millicseconds");
                    second.InnerText = time.Milliseconds.ToString();
                    timeNode.AppendChild(second);

                XmlElement breadcrumb = document.CreateElement("breadcrumb");
                breadcrumb.InnerText = enemy.Breadcrumb.ToString();
                entry.AppendChild(breadcrumb);

                XmlElement enemyNode = document.CreateElement("enemy");
                entry.AppendChild(enemyNode);

                    XmlElement enemyName = document.CreateElement("name");
                    enemyName.InnerText = enemy.name;
                    enemyNode.AppendChild(enemyName);

                    XmlElement enemyPos = document.CreateElement("position");
                    enemyNode.AppendChild(enemyPos);

                        XmlElement enemyX = document.CreateElement("x");
                        enemyX.InnerText = enemy.transform.position.x.ToString();
                        enemyPos.AppendChild(enemyX);

                        XmlElement enemyY = document.CreateElement("y");
                        enemyY.InnerText = enemy.transform.position.y.ToString();
                        enemyPos.AppendChild(enemyY);

                        XmlElement enemyZ = document.CreateElement("z");
                        enemyZ.InnerText = enemy.transform.position.z.ToString();
                        enemyPos.AppendChild(enemyZ);

                XmlElement playerNode = document.CreateElement("player");
                entry.AppendChild(playerNode);

                    XmlElement playerName = document.CreateElement("name");
                    playerName.InnerText = player.name;
                    playerNode.AppendChild(playerName);

                    XmlElement playerPos = document.CreateElement("position");
                    playerNode.AppendChild(playerPos);

                        XmlElement playerX = document.CreateElement("x");
                        playerX.InnerText = player.transform.position.x.ToString();
                        playerPos.AppendChild(playerX);

                        XmlElement playerY = document.CreateElement("y");
                        playerY.InnerText = player.transform.position.y.ToString();
                        playerPos.AppendChild(playerY);

                        XmlElement playerZ = document.CreateElement("z");
                        playerZ.InnerText = player.transform.position.z.ToString();
                        playerPos.AppendChild(playerZ);

            document.Save(filePath);
        }
        else
            Debug.LogError(filePath + " does not exist!");
    }
Beispiel #8
0
    /// <summary>
    /// Initiates the restart of the game only if auto restart is enabled.
    /// </summary>
    protected void InitiateGameRestart(NPCBreadcrumb enemy)
    {
        // Stop time measuring
        measureTime = false;

        if (AutoRestart)
        {
            GameObject player = GameObject.FindGameObjectWithTag("Player");
            playTime.ScaleBy(Time.timeScale);

            xmlWriter.WriteData(playTime, enemy, player);

            StartCoroutine(WaitForGameRestart());
        }
    }