Esempio n. 1
0
    private void MouseOverEnemy(ISelectUnit selectable)
    {
        if (selectable.GetSelectedUnit.transform.parent.parent.gameObject == battleSystem.enemyUnitPlatforms)
        {
            if (selectedEnemyUnit != null)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    battleSystem.Attack(battleSystem.selectedAlliedUnit.GetComponent <Unit>(), selectedEnemyUnit.GetComponent <Unit>());
                }

                if (selectable.GetSelectedUnit != selectedEnemyUnit)
                {
                    SetUnitOutline(selectedEnemyUnit, false);
                    selectedEnemyUnit = selectable.GetSelectedUnit;
                    SetUnitOutline(selectedEnemyUnit, true);

                    Debug.Log("Mouse Over " + selectedEnemyUnit.GetComponent <Unit>().Name);
                }
            }
            else
            {
                selectedEnemyUnit = selectable.GetSelectedUnit;
                SetUnitOutline(selectedEnemyUnit, true);
            }
        }
    }
Esempio n. 2
0
 private void SelectUnit(ISelectUnit selectable)
 {
     if (selectable.GetSelectedUnit.transform.parent.parent.gameObject == battleSystem.alliedUnitPlatforms)
     {
         SetUnitOutline(battleSystem.selectedAlliedUnit, false);
         battleSystem.selectedAlliedUnit = selectable.GetSelectedUnit;
         SetUnitOutline(battleSystem.selectedAlliedUnit, true);
         Debug.Log("Selected Unit " + battleSystem.selectedAlliedUnit.GetComponent <Unit>().UnitData.Name);
     }
 }
Esempio n. 3
0
    private void SelectInput()
    {
        Vector2      worldPoint   = mainCamera.ScreenToWorldPoint(Input.mousePosition);
        RaycastHit2D raycastHit2D = Physics2D.Raycast(worldPoint, Vector2.zero);

        if (raycastHit2D.collider != null && raycastHit2D.collider.GetComponent <ISelectUnit>() != null)
        {
            ISelectUnit selectable = raycastHit2D.collider.GetComponent <ISelectUnit>();
            MouseOverEnemy(selectable);

            if (Input.GetMouseButtonDown(0))
            {
                SelectUnit(selectable);
            }
        }
    }
Esempio n. 4
0
    private void RemoveUnit(RaycastHit2D raycastHit2D)
    {
        ISelectUnit selectable = raycastHit2D.collider.GetComponent <ISelectUnit>();

        if (selectable != null && selectable.GetSelectedUnit.transform.parent.parent.gameObject == battleSystem.alliedUnitPlatforms)
        {
            for (int i = 0; i < battleSystem.alliedUnitPlatforms.GetComponentsInChildren <Unit>().Length; i++)
            {
                if (battleSystem.unitCards.transform.GetChild(i).GetComponent <Unit>().Name == selectable.GetSelectedUnit.GetComponent <Unit>().Name)
                {
                    Unit unit = battleSystem.unitCards.transform.GetChild(i).GetComponent <Unit>();
                    unit.Amount++;

                    selectable.GetSelectedUnit.GetComponent <Unit>().DestroyGameObject();
#if UNITY_EDITOR
                    battleSystem.unitCards.transform.GetChild(i).GetComponent <UnitCardUI>().EditorUnitCardUIUpdate();
#endif
                    Debug.Log("Removed " + unit.Name);
                    break;
                }
            }
        }
    }