Exemple #1
0
    //Receive enemy selection from Battle_Manager and execute action with that target.
    public void TargetEnemy(Battle_Enemy targetedEnemy)
    {
        PossessedEnergy.currentTarget = targetedEnemy;
        PossessedEnergy.Execute();

        Battle_Manager.selectedAction = null;
        Deactivate();
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        UpdatePulseCycle();

        //End battle in victory if there are no enemies left, or defeat if the player's health reaches 0.
        //This currentyl results in infinite pulses being generated over time with nowhere to move.
        if (enemies.Count == 0)
        {
            pulseTravelSpeed = 0;
            foreach (GameObject enemy in enemies)
            {
                enemy.SetActive(false);
            }
            victoryText.SetActive(true);
        }
        else if (player.currentHealth <= 0)
        {
            pulseTravelSpeed = 0;
            foreach (GameObject enemy in enemies)
            {
                enemy.SetActive(false);
            }
            defeatText.SetActive(true);
        }

        //If an enemy is selected after an action, send the action to that enemy.
        //Otherwise, clear the selected enemy.
        if (selectedEnemy != null)
        {
            if (selectedAction != null)
            {
                Debug.Log("Enemy thas been targeted and attacked.");
                selectedAction.TargetEnemy(selectedEnemy);
            }
            else
            {
                selectedEnemy = null;
            }
        }

        //Right mouse button functions.
        if (Input.GetMouseButtonDown(1))
        {
            //Rotate the lifted block.
            if (liftedBlock != null)
            {
                if (liftedBlock.HasEnergy == false)
                {
                    liftedBlock.RotateClockwise();
                }
            }

            //Deselect any selected action.
            if (selectedAction != null)
            {
                selectedAction.Deselect();
                selectedAction = null;
            }
        }

        //Update the node grid whenever a block is placed or removed.
        if (lastLiftedBlock != liftedBlock)
        {
            grid.GetComponent <Grid>().PopulateNodeGrid();
        }

        if (testSave == true)
        {
            grid.GetComponent <Grid>().PopulateSaveData(gridSaveData);
            SaveJsonData(this);
            testSave = false;
        }

        if (testLoad == true)
        {
            LoadJsonData(this);
            testLoad = false;
        }

        lastLiftedBlock = liftedBlock;
    }
Exemple #3
0
 //Remove a dead enemy from the enemies list
 public void DeadEnemy(Battle_Enemy enemy)
 {
     enemies.Remove(enemy.gameObject);
 }