Exemple #1
0
 public void Invoke()
 {
     if (nextIndex >= turretManager.turrets.Length)
     {
         index = -1;
         turret.SetTurret(null);
     }
     else
     {
         GameObject nextTurret = turretManager.turrets[nextIndex];
         index = nextIndex;
         turret.SetTurret(nextTurret);
         turret.turretIndex = index;
     }
     UpdateText();
 }
Exemple #2
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        if (!turretManager)
        {
            turretManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <TurretManager>();
        }
        if (!turretTile)
        {
            turretTile = (TurretTile)target;
            foreach (Transform child in turretTile.turretBase)
            {
                if (child.tag == "Turret")
                {
                    turretTile.SetTurretReference(child.gameObject);
                }
            }
            index = turretTile.turretIndex;
        }

        if (turretManager.turrets.Length < 1)
        {
            GUILayout.Label("No turrets");
            return;
        }

        int nextIndex = index + 1;

        if (nextIndex >= turretManager.turrets.Length)
        {
            if (GUILayout.Button("Remove turret"))
            {
                index = -1;
                turretTile.SetTurret(null);
            }
        }
        else
        {
            GameObject nextTurret = turretManager.turrets[nextIndex];
            if (GUILayout.Button("Change to: " + nextTurret.name))
            {
                index = nextIndex;
                turretTile.SetTurret(nextTurret);
                turretTile.turretIndex = index;
            }
        }
    }