Beispiel #1
0
 //用户输入处理
 private void inputProcess()
 {
     if (Input.GetKeyDown(KeyCode.Alpha1)) //区别GetButtonDown
     {
         addCommand(ENUM_CommandType.ProduceCharacter, new ProduceEnemyCommand());
     }
     else if (Input.GetKeyDown(KeyCode.Alpha2))
     {
         addCommand(ENUM_CommandType.ProduceCharacter, new ProduceSoldierCommand());
     }
     else if (Input.GetKeyDown(KeyCode.Alpha3))
     {
         if (m_characterSystem.getPlayer() == null)
         {
             GameObject mainCamera = UnityTool.findGameObject("Main Camera");
             mainCamera.SetActive(false);
             Cursor.lockState = CursorLockMode.Locked;
             //mainCamera.GetComponent<Camera>().enabled = false;
             addCommand(ENUM_CommandType.ProduceCharacter, new ProducePlayerCommand());
         }
     }
     else if (Input.GetKeyDown(KeyCode.Alpha4))
     {
         getPlayer().addMoveSpeed(2);
     }
     else if (Input.GetKeyDown(KeyCode.Alpha5))
     {
         getPlayer().reduceMoveSpeed(2);
     }
 }
    public void init()
    {
        GameObject obj = UnityTool.findGameObject("Obstacles");

        foreach (Transform child in obj.GetComponentInChildren <Transform>())
        {
            allColliders.Add(child.gameObject);
        }
    }
Beispiel #3
0
 //寻找Canvas下的指定UI界面对象
 public static GameObject findUIGameObject(string UIName)
 {
     if (m_canvasObj == null)
     {
         //保存当前画布,避免重新搜索
         m_canvasObj = UnityTool.findGameObject("Canvas");
     }
     if (m_canvasObj == null) //当前场景无Canvas
     {
         return(null);
     }
     return(UnityTool.findChildGameObject(m_canvasObj, UIName));
 }
Beispiel #4
0
    public void init()
    {
        GameObject obj = UnityTool.findGameObject("WayPoints");

        if (obj == null)
        {
            return;
        }
        foreach (Transform child in obj.GetComponentInChildren <Transform>(true))
        {
            wayPoints.Add(child.gameObject);
        }
        if (wayPoints.Count > 0)
        {
            getOrigin().TargetPos = wayPoints[curNode].transform.position;
        }
    }