Пример #1
0
 // Use this for initialization
 void Start()
 {
     selected = null;
     layerMaskUnits = 1 << 8;
     layerMaskTiles = 1 << 9;
     foreach (ChateauScript chateau in FindObjectsOfType<ChateauScript>())
     {
         if (chateau.owner == "red")
             chateauRed = chateau;
         else
             chateauGreen = chateau;
     }
 }
Пример #2
0
 void Update()
 {
     RaycastHit hit;
     Ray ray;
     if (Input.GetMouseButtonDown(0))
     {
         ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         if (Physics.Raycast(ray, out hit, 100.0f, layerMaskUnits))
         {
             realSelected = hit.collider.gameObject;
             if (realSelected.GetComponent<UnitControlScript>() && realSelected.GetComponent<UnitControlScript>().owner == activePlayer.playerColor)
             {
                 selected = realSelected.GetComponent<UnitControlScript>();
                 writeSelected();
                 HilightTiles(selected.posX, selected.posY, selected.remainingMoves + 1);
             }
             else if (realSelected.GetComponent<ChateauScript>() && realSelected.GetComponent<ChateauScript>().owner == activePlayer.playerColor)
             {
                 chateauSelected = realSelected.GetComponent<ChateauScript>();
                 writeChateau();
             }
             else
                 StartCoroutine(clearSelected());
         }
         else if (Physics.Raycast(ray, out hit, 100.0f, layerMaskTiles)) {
             coords[0] = (int)hit.transform.position.x;
             coords[1] = (int)hit.transform.position.z;
             StartCoroutine(clearSelected());
         }
         else
             StartCoroutine(clearSelected());
     }
     if (Input.GetMouseButtonDown(1) && selected != null)
     {
         ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         if (Physics.Raycast(ray, out hit, 100.0f, layerMaskTiles))
         {
             selected.moveTo((int)hit.transform.position.x, (int)hit.transform.position.z);
             writeSelected();
         }
     }
 }
Пример #3
0
 IEnumerator<WaitForSeconds> clearSelected()
 {
     yield return new WaitForSeconds(0.5f);
     ShutdownTiles();
     detonateButton.SetActive(false);
     selectedPanel.SetActive(false);
     castlePanel.SetActive(false);
     realSelected = null;
     chateauSelected = null;
     selected = null;
 }