Пример #1
0
    private static void Load(string boosterType)
    {
        if (File.Exists(Application.persistentDataPath + "/" + boosterType))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/" + boosterType, FileMode.Open);

            BoosterData data = (BoosterData)bf.Deserialize(file);
            file.Close();
            if (boosterType == booster1Type)
            {
                booster1No = data.numberOfBooster;
                if (booster1No < 0)
                {
                    booster1No = 0;
                }
            }
            else if (boosterType == booster3Type)
            {
                booster3No = data.numberOfBooster;
                if (booster3No < 0)
                {
                    booster3No = 0;
                }
            }
            else if (boosterType == booster4Type)
            {
                booster4No = data.numberOfBooster;
                if (booster4No < 0)
                {
                    booster4No = 0;
                }
            }
            else if (boosterType == booster5Type)
            {
                booster5No = data.numberOfBooster;
                if (booster5No < 0)
                {
                    booster5No = 0;
                }
            }
            else if (boosterType == booster6Type)
            {
                booster6No = data.numberOfBooster;
                if (booster6No < 0)
                {
                    booster6No = 0;
                }
            }
            else if (boosterType == booster7Type)
            {
                booster7No = data.numberOfBooster;
                if (booster7No < 0)
                {
                    booster7No = 0;
                }
            }
        }
    }
Пример #2
0
 private void StopBooster(BoosterData booster)
 {
     if (booster.coroutine != null)
     {
         _mover.ReduceSpeed(booster.value);
         StopCoroutine(booster.coroutine);
         booster.coroutine = null;
     }
 }
Пример #3
0
    public static void Save(int numberOfBooster, string boosterType)
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/" + boosterType);

        BoosterData data = new BoosterData();

        data.numberOfBooster = numberOfBooster;

        bf.Serialize(file, data);
        file.Close();
    }
Пример #4
0
        private void SpawnBooster(Vector2 position, BoosterData boosterData)
        {
            var booster = Object.Instantiate(
                Resources.Load <GameObject>(
                    ResourcesNames.PrefabsNames.BOOSTER
                    )
                )
                          .GetComponent <Booster>();

            booster.Initialize(boosterData);
            booster.transform.position       = position;
            booster.OnCollisionEnter2DEvent += OnBoosterCollisionEnter2D;
        }
Пример #5
0
        private IEnumerator WaitAndReduceSpeed(BoosterData booster)
        {
            yield return(new WaitForSeconds(booster.time));

            StopBooster(booster);
        }
Пример #6
0
 public void Initialize(BoosterData data)
 {
     Data = data;
     GetComponent <SpriteRenderer>().color = data.Color;
 }