コード例 #1
0
ファイル: ShootLocator.cs プロジェクト: YessionCC/PaperWar
 public void Shoot()
 {
     curLand = LandPanel.GetInstance().GetCurPointLand();
     shooter = curLand.GetBuilding().GetComponent <Shooter>();
     StartCoroutine("SelectToLand", shooter);
     MouseStateRecorder.GetInstance().SetCurMouseState(MouseStateRecorder.MouseState.emitBullet);
 }
コード例 #2
0
ファイル: PipeBuilder.cs プロジェクト: YessionCC/PaperWar
    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);
    }
コード例 #3
0
ファイル: MainCamera.cs プロジェクト: YessionCC/PaperWar
 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;
     };
 }
コード例 #4
0
ファイル: PipeButton.cs プロジェクト: YessionCC/PaperWar
    private void OnMouseEnter()
    {
        if (pipe.IfBuilding() || LandPanel.GetInstance().IfAnyPannelShow())
        {
            return;
        }
        PipeUIPannel pannel = PipeUIPannel.GetInstance();

        pannel.SetShowPos(transform.position);
        pannel.SetCurPointPipe(pipe);
        pannel.Show();
    }
コード例 #5
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++;
        }
    }
コード例 #6
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);
    }
コード例 #7
0
ファイル: PipeBuilder.cs プロジェクト: YessionCC/PaperWar
 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);
 }
コード例 #8
0
 private void BuildBuilding()
 {
     LandPanel.GetInstance().ToShow(BuilderPanel.GetInstance() as IPannelInterface);
 }
コード例 #9
0
 void Start()
 {
     GetComponent <Image>().alphaHitTestMinimumThreshold = 0.1f;
     curFunction = Land.LandFunction.none;
     landPanel   = LandPanel.GetInstance();
 }
コード例 #10
0
ファイル: BuildingBuilder.cs プロジェクト: YessionCC/PaperWar
    public void Build(BuildingType buildingType)
    {
        Land land = LandPanel.GetInstance().GetCurPointLand();

        Build(buildingType, land);
    }