Exemplo n.º 1
0
    public virtual void Die()
    {
        isLive = false;
        switch (parent.Type)
        {
        case Unit.UnitType.Zombie:
        {
            MarkersManager.inst.RemoweEnemy(parent);
            break;
        }

        case Unit.UnitType.Soldier:
        {
            MarkersManager.inst.RemoweUnit(parent);
            break;
        }

        case Unit.UnitType.Base:
        {
            DPanel.Add(this, "<color=red>PLAYER LOSE</color>");
            DPanel.Add(this, "<color=red>PLAYER LOSE</color>");
            DPanel.Add(this, "<color=red>PLAYER LOSE</color>");
            break;
        }
        }

        Destroy(parent.gameObject, 2f);
    }
Exemplo n.º 2
0
 public void MarkerTracked(Marker marker)
 {
     if (marker.Type == Marker.MarkerType.MainBase)
     {
         mainBase = marker;
     }
     else
     {
         if (matchs.Count > 0)
         {
             foreach (var m in matchs)
             {
                 if (m.isLackMarker())
                 {
                     m.Set(marker);
                     DPanel.Add(this, string.Format("New marker type <color=yellow>[{0}]</color> was <color=red>replace</color>", marker.Type));
                     return;
                 }
             }
         }
         matchs.Add(new MatchMarkersUnits(marker));
         DPanel.Add(this, string.Format("New marker type <color=yellow>[{0}]</color> was <color=green>added</color>", marker.Type));
     }
     //DPanel.Add(this, string.Format("New marker type <color=yellow>[{0}]</color> was <color=red>ADDED</color> to array with ID <color=blue>[{1}]</color>", marker.Type, marker.ID));
 }
Exemplo n.º 3
0
 public virtual void GetDamage(IAttack enemy)
 {
     CurrentHealth -= (enemy.AttackDamage - Armor);
     if (parent.Type != Unit.UnitType.Base)
     {
         GamePlayMenuHandler.inst.UpdateHPBarForUnit(parent, CurrentHealth);
     }
     if (parent.Type != Unit.UnitType.Base)
     {
         GamePlayMenuHandler.inst.UpdateHPBarForTower(parent, CurrentHealth);
     }
     if (CurrentHealth < 0)
     {
         DPanel.Add(this, "Unit type <color=yellow>[" + parent.Type + "]</color> was <color=red>DIE</color>");
         if (parent.Type == Unit.UnitType.Zombie)
         {
             GamePlayMenuHandler.inst.SetEnemiesCount(++GamePlayMenuHandler.inst.EnemyKilled);
         }
         if (parent.Type == Unit.UnitType.Soldier)
         {
             GamePlayMenuHandler.inst.SetSoldiersCount(--GamePlayMenuHandler.inst.SoldierAlive);
         }
         Die();
         return;
     }
     if (parent != null && parent.AttackController != null)
     {
         parent.AttackController.UnderAttack(enemy);
     }
 }
Exemplo n.º 4
0
    public void SpawnNewUnit()
    {
        if (unitPrefab == null)
        {
            return;
        }
        var MB = MarkersManager.inst.GetMainBase();

        if (MB == null)
        {
            return;
        }
        if (GamePlayMenuHandler.inst.GetCurStage(MenuUICanvas.inst.GetStageCount()).SoldiersCount <= GamePlayMenuHandler.inst.SoldierAlive)
        {
            return;
        }
        if (MarkersManager.inst.CanCreateNewSoldier())
        {
            var u = Instantiate(unitPrefab, MB.position, MB.rotation, transform).GetComponent <Unit>();
            GamePlayMenuHandler.inst.SetSoldiersCount(++GamePlayMenuHandler.inst.SoldierAlive);
            if (u == null)
            {
                Destroy(u);
                return;
            }
            MarkersManager.inst.AddNewUnit(u);
        }
        else
        {
            DPanel.Add(this, "New UNIT <color=red>can't be created</color>");
        }
    }
Exemplo n.º 5
0
 public void AddNewUnit(Unit unit)
 {
     if (CanCreateNewSoldier())
     {
         unit.Target = GetFreeMarker(unit).MarkerPosition;
         units.Add(unit);
         DPanel.Add(this, string.Format("New UNIT type <color=yellow>[{0}]</color> was <color=red>ADDED</color> to array with ID <color=blue>[{1}]</color>", unit.Type, unit.ID));
     }
 }
Exemplo n.º 6
0
 public void RemoweUnit(Unit unit)
 {
     units.Remove(unit);
     if (matchs.Count > 0)
     {
         foreach (var m in matchs)
         {
             m.Remove(unit);
         }
     }
     DPanel.Add(this, string.Format("UNIT type <color=yellow>[{0}]</color> was <color=red>REMOWED</color> from array with ID <color=blue>[{1}]</color>", unit.Type, unit.ID));
 }
Exemplo n.º 7
0
 public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus)
 {
     if (newStatus == TrackableBehaviour.Status.TRACKED)
     {
         MarkersManager.inst.MarkerTracked(this);
         istracked = true;
         DPanel.Add(this, string.Format("<color=green>Find</color> marker type <color=yellow>[{0}]</color> with ID<color=blue>[{1}]</color>", Type, ID));
     }
     else
     {
         istracked = false;
         MarkersManager.inst.MarkerLost(this);
         DPanel.Add(this, string.Format("<color=red>Lost</color> marker type <color=yellow>[{0}]</color> with ID<color=blue>[{1}]</color>", Type, ID));
     }
 }
Exemplo n.º 8
0
 IEnumerator DoAttack()
 {
     while (target != null && target.isLive)
     {
         isCoroutineStart = true;
         target.GetDamage(this);
         parent.transform.LookAt(new Vector3((target.transform.position.x), 0, (target.transform.position.z)));
         DPanel.Add(this, string.Format("Unit <color=yellow>{0}</color> attacks unit <color=red>{1}</color>", parent.Type, target.parent.Type));
         yield return(new WaitForSeconds(TimeBeforeAttacks));
     }
     if (parent.Type == Unit.UnitType.Zombie)
     {
         parent.MoveController.Target = MarkersManager.inst.mainBase.MarkerPosition;
     }
     isAttack         = false;
     isCoroutineStart = false;
     StopCoroutine(DoAttack());
 }
Exemplo n.º 9
0
 public void AddNewEnemy(Unit unit)
 {
     unit.Target = mainBase.MarkerPosition;
     enemys.Add(unit);
     DPanel.Add(this, string.Format("New UNIT type <color=yellow>[{0}]</color> was <color=red>ADDED</color> to array with ID <color=blue>[{1}]</color>", unit.Type, unit.ID));
 }
Exemplo n.º 10
0
 public void OnButtonReleased(VirtualButtonBehaviour vb)
 {
     Debug.Log("OnButtonReleased");
     DPanel.Add(this, string.Format("Virtual button was <color=red>released</color> with name <color=blue>[]</color>", vb.name));
 }
Exemplo n.º 11
0
 // Called when the virtual button has just been pressed:
 public void OnButtonPressed(VirtualButtonBehaviour vb)
 {
     DPanel.Add(this, string.Format("Virtual button was <color=red>click</color> with name <color=blue>[]</color>", vb.name));
     spawner.SpawnNewUnit();
 }