예제 #1
0
 private void Update()
 {
     if (Input.GetButtonDown("AddCube") && !PlayerCommands.Get().isAddingTurret)
     {
         TryAddCubo();
     }
 }
예제 #2
0
    public override void OnWork(CuboController user)
    {
        PlayerCommands.Get().OnCuboDestroyed();
        user.GetComponentInChildren <Selectable>().enabled = false;

        GameObject model = user.model;

        model.transform.DOPunchScale(new Vector3(1.025f, 0.8f, 1.025f), 0.25f, 0, 2f);

        Sequence seq = DOTween.Sequence();

        seq.Append(model.transform.DOLocalMoveY(5f, sacrificeTime).SetEase(Ease.InQuad));
        seq.Join(model.transform.DOScale(0f, sacrificeTime - 0.4f).SetEase(Ease.InQuad).SetDelay(0.4f));
        seq.Play();

        Camera.main.GetComponent <AudioSource>().PlayOneShot(sacrificeNoise);

        Timing.CallDelayed(sacrificeTime + 0.1f, delegate
        {
            Instantiate(workFxObj, transform.position + Vector3.up * 17f, Quaternion.LookRotation(Vector3.up, Vector3.left));
            power++;
            UIStatic.SetInt(UIStatic.CUR_SACRIFICE, power);
            Destroy(user.gameObject);

            if (power >= goalPower)
            {
                PlayerCommands.Get().Win();
            }
        });
    }
예제 #3
0
    void Update()
    {
        if (Input.GetButtonDown("AddTurret"))
        {
            TryAddTurret();
        }

        turretCost.text = PlayerCommands.Get().GetCurTurretCost().ToString();
    }
예제 #4
0
 public override void OnWork(CuboController user)
 {
     base.OnWork(user);
     if (!users.Contains(user))
     {
         users.Add(user);
     }
     PlayerCommands.Get().AddMoney(GetMoneyPerWork(user));
     Camera.main.GetComponent <AudioSource>().PlayOneShot(moneyNoise);
 }
예제 #5
0
    void TryAddTurret()
    {
        if (PlayerCommands.Get().isAddingTurret)
        {
            return;
        }

        if (PlayerCommands.Get().TryAddTurret())
        {
        }
        else
        {
            moneyCounter.FlashRed();
        }
    }
예제 #6
0
    public void TryAddCubo()
    {
        if (!PlayerCommands.Get().EnoughRoomForCubos())
        {
            curCubos.FlashRed();
            return;
        }

        if (PlayerCommands.Get().TryAddCubo())
        {
            //play sound and stuff
        }
        else
        {
            moneyCounter.FlashRed();
        }
    }
예제 #7
0
 // Update is called once per frame
 void Update()
 {
     if (UIStatic.HasInt(UIStatic.CUR_CUBOS))
     {
         text.text = UIStatic.GetInt(UIStatic.CUR_CUBOS).ToString();
     }
     if (!PlayerCommands.Get().EnoughRoomForCubos())
     {
         label.color = flashRedColor;
         text.color  = flashRedColor;
     }
     else
     {
         label.color = m_textStartColor;
         text.color  = m_textStartColor;
     }
 }
예제 #8
0
    public override void OnDeath()
    {
        base.OnDeath();
        Camera.main.GetComponent <AudioSource>().PlayOneShot(explodeNoise);
        bool lose = true;

        foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Building"))
        {
            if (obj.GetComponent <Health>().IsAlive())
            {
                lose = false;
                break;
            }
        }
        if (lose)
        {
            PlayerCommands.Get().Lose();
        }
    }
예제 #9
0
    void Update()
    {
        if (PlayerCommands.Get().isEnding)
        {
            return;
        }

        if (PlayerCommands.Get().isAddingTurret || PlayerCommands.Get().lastAddingTurretTime == Time.time)
        {
            ClearSelected();
            isSelecting = false;
            return;
        }

        if (Input.GetButtonDown("ClearSelection"))
        {
            ClearSelected();
        }

        if (Input.GetButtonDown("Select"))
        {
            if (Camera.main.ScreenToViewportPoint(Input.mousePosition).y < .1026f)
            {
                //ui bar hack
                return;
            }

            Ray        mouseToWorldRay = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hitInfo;
            if (Physics.Raycast(mouseToWorldRay, out hitInfo, 1000f, selectionLayerMask, QueryTriggerInteraction.Ignore))
            {
                if (hitInfo.collider.gameObject.layer == LayerMask.NameToLayer("UI"))
                {
                    return;
                }

                Selectable s = hitInfo.collider.GetComponentInParent <Selectable>();
                if (s != null)
                {
                    if (Input.GetButton("AdditiveModifier"))
                    {
                        UpdateSelection(s, !s.isSelected);
                    }
                    else
                    {
                        ClearSelected();
                        UpdateSelection(s, true);
                    }

                    return;
                }
            }
            else if (!Input.GetButton("AdditiveModifier"))
            {
                foreach (Selectable selectable in selectables)
                {
                    UpdateSelection(selectable, false);
                }
            }

            if (selectionBox == null)
            {
                return;
            }
            //Storing these variables for the selectionBox
            startScreenPos = Input.mousePosition;
            isSelecting    = true;
        }

        //If we never set the selectionBox variable in the inspector, we are simply not able to drag the selectionBox to easily select multiple objects. 'Regular' selection should still work
        if (selectionBox == null)
        {
            return;
        }

        //We finished our selection box when the key is released
        if (Input.GetMouseButtonUp(0))
        {
            isSelecting = false;
        }

        selectionBox.gameObject.SetActive(isSelecting);

        if (isSelecting)
        {
            Bounds b = new Bounds();
            //The center of the bounds is inbetween startpos and current pos
            b.center = Vector3.Lerp(startScreenPos, Input.mousePosition, 0.5f);
            //We make the size absolute (negative bounds don't contain anything)
            b.size = new Vector3(Mathf.Abs(startScreenPos.x - Input.mousePosition.x),
                                 Mathf.Abs(startScreenPos.y - Input.mousePosition.y),
                                 0);

            //To display our selectionbox image in the same place as our bounds
            rt.position  = b.center;
            rt.sizeDelta = canvas.transform.InverseTransformVector(b.size);

            //Looping through all the selectables in our world (automatically added/removed through the Selectable OnEnable/OnDisable)
            foreach (Selectable selectable in selectables)
            {
                //If the screenPosition of the worldobject is within our selection bounds, we can add it to our selection
                Vector3 screenPos = Camera.main.WorldToScreenPoint(selectable.transform.position);
                screenPos.z = 0;
                bool isSelected = b.Contains(screenPos);
                if (Input.GetButton("AdditiveModifier") && !isSelected)
                {
                    continue;
                }

                UpdateSelection(selectable, isSelected);
            }
        }
    }
예제 #10
0
 void Start()
 {
     GetComponent <Button>().onClick.AddListener(OnButtonClick);
     turretCost.text = PlayerCommands.Get().addTurretCostStart.ToString();
 }