Exemple #1
0
 public void Shoot()
 {
     curLand = LandPanel.GetInstance().GetCurPointLand();
     shooter = curLand.GetBuilding().GetComponent <Shooter>();
     StartCoroutine("SelectToLand", shooter);
     MouseStateRecorder.GetInstance().SetCurMouseState(MouseStateRecorder.MouseState.emitBullet);
 }
Exemple #2
0
 private void Awake()
 {
     Instance        = this;
     isAnyPannelShow = false;
     pannelStack     = new Stack <IPannelInterface>();
     allPannels      = transform.GetComponentsInChildren <IPannelInterface>();
 }
Exemple #3
0
    public void BuildPipe()
    {
        Land landFrom = LandPanel.GetInstance().GetCurPointLand();
        Pipe pipe     = Instantiate(pipePrefab.gameObject, landFrom.transform.position, Quaternion.identity).GetComponent <Pipe>();

        pipe.SetFrom(landFrom);
        StartCoroutine("SelectToLand", pipe);
        MouseStateRecorder.GetInstance().SetCurMouseState(MouseStateRecorder.MouseState.buildPipe);
    }
Exemple #4
0
 private void Start()
 {
     moveState          = MoveState.none;
     _camera            = GetComponent <Camera>();
     toOrthographicSize = _camera.orthographicSize;
     LandPanel.GetInstance().OnPointLandChange += (object o, EventArgs e) => {
         Vector3 pos = LandPanel.GetInstance().GetCurPointLand().transform.position;
         moveTo    = new Vector3(pos.x, pos.y, transform.position.z);
         moveState = MoveState.moveTo;
     };
 }
Exemple #5
0
    private void OnMouseEnter()
    {
        if (pipe.IfBuilding() || LandPanel.GetInstance().IfAnyPannelShow())
        {
            return;
        }
        PipeUIPannel pannel = PipeUIPannel.GetInstance();

        pannel.SetShowPos(transform.position);
        pannel.SetCurPointPipe(pipe);
        pannel.Show();
    }
Exemple #6
0
    public void Show()
    {
        gameObject.SetActive(true);
        StartCoroutine("ShowAnimation");
        int index = 0;

        foreach (Land.LandFunction function in
                 LandPanel.GetInstance().GetCurPointLand().GetLandFunctions())
        {
            buttons[index].gameObject.SetActive(true);
            buttons[index].SetFunction(function);
            buttonImg[index].sprite = functionSprite[function];
            index++;
        }
    }
Exemple #7
0
    public void Show()
    {
        int idx = 0;

        foreach (BuildingBuilder.BuildingType buildingType in BuildingBuilder.GetInstance().buildingCanBuild)
        {
            buttons[idx].gameObject.SetActive(true);
            buttonImg[idx].sprite = buildingTypeSprite[buildingType];
            if (buildingType == BuildingBuilder.BuildingType.back)
            {
                buttons[idx].onClick.AddListener(() => { LandPanel.GetInstance().ToBack(); });
            }
            else
            {
                buttons[idx].onClick.AddListener(() => {
                    BuildingBuilder.GetInstance().Build(buildingType);
                    LandPanel.GetInstance().HideAll();
                });
            }
            idx++;
        }
        gameObject.SetActive(true);
    }
Exemple #8
0
 IEnumerator SelectToLand(Pipe pipe)
 {
     while (true)
     {
         Vector2 point = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         pipe.Stretch(point, pipe.GetLength(point) < maxPipeLen);
         if (Input.GetMouseButtonDown(0))
         {
             RaycastHit2D hit = Physics2D.Raycast(point, Vector2.zero);
             if (hit.collider)
             {
                 Land  land = hit.collider.GetComponent <Land>();
                 float dis  = 0;
                 if (land != null &&
                     !land.Equals(LandPanel.GetInstance().GetCurPointLand()) && //不建立自己到自己的pipe
                     pipe.GetPlayer().Equals(land.GetPlayer()) &&               //不建立自己到别人的pipe
                     (dis = pipe.GetLength(point)) < maxPipeLen)                //不能太长
                 {
                     PlayerDataRequire dataRequire = new PlayerDataRequire(PlayerData.PlayerDataEnum.capital, -(int)(pipeCostPerLen * dis));
                     bool ret = pipe.GetPlayer().GetData().UpdateData(dataRequire, false);
                     if (!ret)
                     {
                         break;       //资金不够
                     }
                     pipe.GetPlayer().GetData().UpdateData(dataRequire, true);
                     pipe.SetToLand(land);
                     break;
                 }
             }
             Destroy(pipe.gameObject);
             break;
         }
         yield return(0);
     }
     MouseStateRecorder.GetInstance().SetCurMouseState(MouseStateRecorder.MouseState.normal);
 }
Exemple #9
0
 private void BuildBuilding()
 {
     LandPanel.GetInstance().ToShow(BuilderPanel.GetInstance() as IPannelInterface);
 }
Exemple #10
0
 void Start()
 {
     GetComponent <Image>().alphaHitTestMinimumThreshold = 0.1f;
     curFunction = Land.LandFunction.none;
     landPanel   = LandPanel.GetInstance();
 }
Exemple #11
0
    public void Build(BuildingType buildingType)
    {
        Land land = LandPanel.GetInstance().GetCurPointLand();

        Build(buildingType, land);
    }