public override void ButtonDown()
    {
        GameSession session = GameSession.Instance;

        if (session.isNetworkGame)
        {
            if (!processing)
            {
                if (PausableMonoBehaviour.isPaused)
                {
                    session.RequestResume();
                }
                else
                {
                    session.RequestPause();
                }
            }
        }
        else
        {
            if (!processing)
            {
                if (!PausableMonoBehaviour.isPaused)
                {
                    ScreenDebugger.addText("Paws");
                    PausableMonoBehaviour.Pause();
                }
                else
                {
                    ScreenDebugger.addText("Un-paws");
                    PausableMonoBehaviour.Resume();
                }
            }
        }
    }
Exemple #2
0
 void ButtonDown()
 {
     if (!PausableMonoBehaviour.isPaused && GameSession.Instance.isDefender)
     {
         ScreenDebugger.addText("teh-rain");
         GameSession.Instance.refreshSelected();
     }
 }
    public override void ButtonDown()
    {
        ScreenDebugger.addText("De-wete");
        Tower tower = ((Tower)GameSession.Instance.selectedObject);

        GameSession.Instance.selectedObject.Deselect();
        tower.Sell();
        UIBlockLower.Instance.guiTexture.texture = PrefabManager.UIBlockLowerDefault;
        UITowerSelectedCard.Instance.hide();
        UITowerUpgradeCard.Instance.hide();
    }
Exemple #4
0
    void panTouch()
    {
        if (Input.touchCount == 1)
        {
            if (Input.GetTouch(0).phase == TouchPhase.Moved)
            {
                Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
                if (touchDeltaPosition.magnitude > minPanMagnitude)
                {
                    transform.Translate(-touchDeltaPosition.x * touchDragSpeed, 0, -touchDeltaPosition.y * touchDragSpeed);
                    Vector3 pos = transform.position;
                    transform.position = new Vector3(Mathf.Clamp(pos.x, cameraMinX, cameraMaxX), cameraY, Mathf.Clamp(pos.z, cameraMinZ, cameraMaxZ));
                }
            }
        }
        else if (Input.touchCount == 2)
        {
            if (Input.GetTouch(0).phase == TouchPhase.Moved &&
                Input.GetTouch(1).phase == TouchPhase.Moved)
            {
                ScreenDebugger.addText("Zooming");
                curDist     = Input.GetTouch(0).position - Input.GetTouch(1).position;                                                                           //current distance between finger touches
                prevDist    = ((Input.GetTouch(0).position - Input.GetTouch(0).deltaPosition) - (Input.GetTouch(1).position - Input.GetTouch(1).deltaPosition)); //difference in previous locations using delta positions
                touchDelta  = curDist.magnitude - prevDist.magnitude;
                speedTouch0 = Input.GetTouch(0).deltaPosition.magnitude / Input.GetTouch(0).deltaTime;
                speedTouch1 = Input.GetTouch(1).deltaPosition.magnitude / Input.GetTouch(1).deltaTime;
                if (speedTouch0 > minPinchSpeed &&
                    speedTouch1 > minPinchSpeed)
                {
                    float fov = Camera.main.fieldOfView;
                    if (touchDelta + varianceInDistances <= 1)
                    {
                        //zooming out
                        ScreenDebugger.addText("Zooming out");
                        fov -= touchDelta * pinchZoomOutSpeed;
                    }
                    else if (touchDelta + varianceInDistances > 1)
                    {
                        //zooming in
                        fov -= touchDelta * pinchZoomInSpeed;
                        ScreenDebugger.addText("Zooming in");
                    }
                    else
                    {
                        return;
                    }

                    fov = Mathf.Clamp(fov, minFov, maxFov);
                    Camera.main.fieldOfView = fov;
                }
            }
        }
    }
    protected override void handleButtonDown()
    {
        ScreenDebugger.addText("ey-lee-an");
        GameSession session = GameSession.Instance;

        if (!session.isDefender)
        {
            if (session.selectedObject != null &&
                session.selectedObject != this)
            {
                session.selectedObject.Deselect();
            }

            Select();
        }
        else
        {
            ScreenDebugger.addText("Deselecting");
            session.refreshSelected();
        }
    }
Exemple #6
0
    public override void ButtonDown()
    {
        ScreenDebugger.addText(ability.ToString());
        GameSession session = GameSession.Instance;

        if (session.isDefender)
        {
            if (session.disableTouch)
            {
                return;
            }

            if (session.selectedObject is Tower)
            {
                // Cancel tower selection
                session.selectedObject.Deselect();
            }

            if (session.selectedCard != null &&
                session.selectedCard != this)
            {
                session.selectedCard.Deselect();
            }

            if (session.selectedObject == null)
            {
                if (session.selectedCard == this)
                {
                    // Double-tapping is a deselect
                    Deselect();
                }
                else
                {
                    // Just select
                    Select();
                    SelectableObject.showAll = true;
                    guiTexture.texture       = PrefabManager.PrefabCards[ability.ToString() + "Selected"];
                }
            }
            else
            {
                if (session.selectedCard == this)
                {
                    // Build tower

                    string abilityS = ability.ToString();
                    if (Constants.TowerBuildCosts[abilityS] <= session.credits)
                    {
                        Tower tower = Tower.Create(ability.ToString(), (TowerSpawnPoint)session.selectedObject);
                        tower.Select();
                    }
                    else
                    {
                        // Do something here
                    }
                }
                else
                {
                    // Change selection
                    Select();
                    session.showConfirmation();
                }
            }
        }
        else
        {
            if (session.selectedObject is AlienSpawnPoint)
            {
                guiTexture.texture = PrefabManager.PrefabCards[ability.ToString() + "Selected"];
                AlienSpawnPoint spawn = (AlienSpawnPoint)GameSession.Instance.selectedObject;
                if (session.selectedCard == this && (enabledTable[spawn] == null || (bool)enabledTable[spawn] == true))
                {
                    if (session.tick <= 0)
                    {
                        // Cannot spawn when time is up
                        return;
                    }
                    string abilityString = ability.ToString();
                    if (session.credits >= Constants.AlienCost[abilityString])
                    {
                        session.credits -= Constants.AlienCost[abilityString];
                        AlienSpawnPoint sp            = (AlienSpawnPoint)session.selectedObject;
                        int             spawnPointPos = Array.IndexOf(GameStart.Instance.spawnPoints, sp);
                        int             routePos      = UnityEngine.Random.Range(0, sp.routes.Length);
                        session.SpawnUnit(abilityString, spawnPointPos, routePos);

                        enabledTable[spawn] = false;

                        StartCoroutine(Cooldown(spawn));
                    }
                    else
                    {
                        // TODO complain not enuff credits somehow!
                    }
                }
                else
                {
                    if (session.selectedCard != null && session.selectedCard != this)
                    {
                        session.selectedCard.Deselect();
                    }
                    Select();
                }
            }
        }
    }