Esempio n. 1
0
    void endGame()
    {
        isDead       = true;
        forwardSpeed = 0;
        StartCoroutine(death());
        SkySpeedScript.setSpeed(0);
        EnemyPosScript.setSpeed(0);
        FirstLaunchScript.ins.SaveToCloud();
        AchievementManager.ins.killCount = 0;
        //EndScreenUI.setPanelActive();
        setEndScreenActive();
        if (distance > 10)
        {
            checkShowAd();
        }

        checkHiScore(distance);

        if (Social.localUser.authenticated)
        {
            Social.ReportScore((long)distance, CoffeeHerosResources.leaderboard_distance, (bool success) => { });
        }

        PlayerPrefs.SetInt("BonusBiscuits", 1);
        PlayerPrefs.Save();
    }
Esempio n. 2
0
    public static void LoadSave()
    {
        //print("loading");
        // string filePath = Application.persistentDataPath + gameDataPath;

        /*
         * if (File.Exists(filePath)) {
         *  print("found game");
         *  //Save save = JsonUtility.FromJson<Save>(File.ReadAllText(filePath));
         *  InventoryScript.ReadFromSave(save);
         *  ItemLoadScript.ReadFromSave(save);
         *  EnemyPosScript.ReadFromSave(save);
         *  SceneManager.LoadScene(save.savedScene);
         * }
         * else {
         *  StartGame();
         * }*/
        if (officialState == null)
        {
            StartGame();
        }
        else
        {
            InventoryScript.ReadFromSave(officialState);
            ItemLoadScript.ReadFromSave(officialState);
            EnemyPosScript.ReadFromSave(officialState);
            SceneManager.LoadScene(officialState.savedScene);
        }
    }
Esempio n. 3
0
    public static Save CreateSaveGameObject()
    {
        Save save = new Save();

        InventoryScript.PopulateSave(save);
        ItemLoadScript.PopulateSave(save);
        EnemyPosScript.PopulateSave(save);
        return(save);
    }
Esempio n. 4
0
 public static void StartGame()
 {
     InventoryScript.LoadDefault();
     ItemLoadScript.LoadDefault();
     EnemyPosScript.LoadDefault();
     SceneManager.LoadScene("Closet");
     officialState               = CreateSaveGameObject();
     officialState.savedScene    = "Closet";
     officialState.checkpointNum = -1;
 }
Esempio n. 5
0
 // Use this for initialization
 void Start()
 {
     targets            = new Transform[3];
     targets[2]         = PlayerScript.GetPlayer().transform;
     rigidbody          = GetComponent <Rigidbody2D>();
     spriteRenderer     = GetComponent <SpriteRenderer>();
     speed              = 0.1f;
     currtarget         = 2;
     lagtime            = 100;
     collided           = false;
     transform.position = EnemyPosScript.GetPosition(index, transform.position);
 }
Esempio n. 6
0
 void startGame()
 {
     velocity      = Vector3.zero;
     forwardSpeed  = baseSpeed;
     isDead        = false;
     numOfLives    = 3;
     numOfShots    = 3;
     distance      = 0;
     timer         = 0;
     oneRunBiscuit = 0;
     SkySpeedScript.setSpeed(SkySpeedScript.constSpeed);
     EnemyPosScript.setSpeed(EnemyPosScript.constSpeed);
     isStart = false;
 }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        if (PlayerScript.Active)
        {
            if (lagtime == 0)
            {
                lagtime = 100;
                speed  += 0.01f;
            }
            lagtime--;
            //Debug.Log("targets[currtarget].position.y: " + targets[currtarget].position.y);
            //Debug.Log("speed: " + speed);
            bool checkY = targets[currtarget].position.y - speed / 2 < transform.position.y &&
                          transform.position.y < targets[currtarget].position.y + speed / 2;
            bool checkX = targets[currtarget].position.x - speed / 2 < transform.position.x &&
                          transform.position.x < targets[currtarget].position.x + speed / 2;
            if (checkX && checkY)
            {
                currtarget++;
                return;
            }
            if (!collided)
            {
                if (checkX)
                {
                    prioritizeY = true;
                }
                else if (checkY)
                {
                    prioritizeY = false;
                }
            }
            collided = false;

            if (prioritizeY)
            {
                if (transform.position.y < targets[currtarget].transform.position.y)
                {
                    movementVector        = new Vector2(0, speed);
                    spriteRenderer.sprite = sprites[0];
                }
                else
                {
                    movementVector        = new Vector2(0, -speed);
                    spriteRenderer.sprite = sprites[1];
                }
            }
            else
            {
                if (transform.position.x < targets[currtarget].transform.position.x)
                {
                    movementVector        = new Vector2(speed, 0);
                    spriteRenderer.sprite = sprites[2];
                }
                else
                {
                    movementVector        = new Vector2(-speed, 0);
                    spriteRenderer.sprite = sprites[3];
                }
            }
            rigidbody.MovePosition(rigidbody.position + movementVector);
            EnemyPosScript.UpdatePosition(index, transform.position);
            //print(index + ": " + prioritizeY);
        }
    }