// Use this for initialization
    void Start()
    {
        //applyPlayerStats(1, 1, 1, 1, 1, 1, 1);

        if (!SaveScript.isReset)
        {
            cash = double.Parse(SaveScript.savedData["CurrencyCash"].ToString());
            ApplyPlayerStats((int)SaveScript.savedData["PlayerDamage"],
                             (int)SaveScript.savedData["PlayerSpeed"],
                             (int)SaveScript.savedData["PlayerReach"],
                             (int)SaveScript.savedData["PlayerCritChance"],
                             (int)SaveScript.savedData["PlayerCritDamage"],
                             (int)SaveScript.savedData["PlayerLuck"],
                             (int)SaveScript.savedData["PlayerJet"]);

            xp = new XPSystem(1, 1, 15, 1.15f);
        }
        else
        {
            ApplyPlayerStats(1, 1, 1, 1, 1, 1, 1);
            xp   = new XPSystem(1, 1, 15, 1.15f);
            cash = 0;
        }
        speedStore = stats["speed"].finalValue;

        //message = GameObject.Find("GameManager").GetComponent<MessageSystem>();

        playerControl = true;
        //cash = 1000000000;
    }
Exemple #2
0
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(this.gameObject);
            return;
        }

        instance = this;
    }
Exemple #3
0
 private void Awake()
 {
     instance = this;
 }
    // public void PlaceFeedbackText(int i)
    // {
    //     Transform tileTransform = tiles_[i].transform;
    //     Canvas canvas = GameObject.Find("Canvas");
    //     Text feedback = (Text)Instantiate(textPrefab, tileTransform.position, tileTransform.rotation);
    //     feedback.transform.SetParent(canvas.transform, false);
    //     feedback.fontSize = 14;
    //     feedback.text = "asdlfkjsdfkj";
    // }

    public void Update()
    {
        // The mouse position is in screen pixel coordinates, and we need to
        // center it relative to the world.
        Vector3         mouse_in_world = MouseInWorld();
        BuildingManager active         = GetActiveTile(mouse_in_world.x, mouse_in_world.y);

        if (activeTile != null)
        {
            activeTile.Highlight(false); // Turn off previously active tile.
        }
        activeTile = active;
        activeTile.Highlight(true);

        // if the mouse button is held down, create a disaster in the correct section
        if (Input.GetMouseButtonDown(0))
        {
            if (selectedDisaster == DisasterType.Meteor)
            {
                SceneManager.LoadScene("winScene");
            }

            int activeI = GetActiveIndex(mouse_in_world.x, mouse_in_world.y);

            Vector2 mouse_in_world_2d = new Vector2(mouse_in_world.x, mouse_in_world.y);
            float   clickRadius       = mouse_in_world_2d.magnitude;

            if (selectedDisaster != DisasterType.NotSelected &&
                clickRadius >= earthRadius &&
                clickRadius <= 2 * earthRadius)
            {
                PlaceDisaster(activeI);

                Type     SelectedDisasterT = DisasterTypeToClass[selectedDisaster];
                Disaster instance          = (Disaster)Activator.CreateInstance(SelectedDisasterT);

                // Start the disaster cooldown.
                if (enableCooldown)
                {
                    selectedButton.DisableForCountdown(instance.cooldownTime);
                    selectedDisaster = DisasterType.NotSelected;
                }

                bool destroyed = active.Attack(instance);

                if (destroyed)
                {
                    XPSystem system  = xpSlider.GetComponent <XPSystem>();
                    float    xpLevel = system.EarnXP(active.building.xpGain);

                    simulator.KillPopulation(active.building.populationPct);
                    simulator.KillTechnology(active.building.technologyPct);

                    activeTile.Destroy(instance);

                    ToolbarManager tManager = toolbar.GetComponent <ToolbarManager>();
                    if (xpLevel >= 1.0f)
                    {
                        tManager.UnlockButton(4);
                    }
                    else if (xpLevel >= 0.60f)
                    {
                        tManager.UnlockButton(3);
                    }
                    else if (xpLevel >= 0.25f)
                    {
                        tManager.UnlockButton(2);
                    }
                    else if (xpLevel >= 0.1f)
                    {
                        tManager.UnlockButton(1);
                    }
                }
            }
        }
    }