Exemplo n.º 1
0
    public static TimeAttack Load()
    {
        if (PlayerPrefs.HasKey($"challenge.id"))
        {
            var stats = new TimeAttack();

            stats.id           = PlayerPrefs.GetInt($"challenge.id");
            stats.time         = PlayerPrefs.GetInt($"challenge.time");
            stats.difficulty   = PlayerPrefs.GetInt($"challenge.difficulty");
            stats.clearedCount = PlayerPrefs.GetInt($"challenge.cleared");
            stats.seed         = PlayerPrefs.GetInt($"challenge.seed");
            stats.totalTime    = PlayerPrefs.GetFloat($"challenge.totalTime");
            stats.totalCoin    = PlayerPrefs.GetInt($"challenge.totalCoin");
            stats.totalMiss    = PlayerPrefs.GetInt($"challenge.totalMiss");

            if (PlayerPrefs.HasKey($"challenge.stage.id"))
            {
                var id   = PlayerPrefs.GetInt($"challenge.stage.id");
                var seed = PlayerPrefs.GetInt($"challenge.seed");
                var size = new Vector2Int(PlayerPrefs.GetInt($"challenge.stage.size.x"), PlayerPrefs.GetInt($"challenge.stage.size.y"));
                stats.currentStage = new FloorSettings(id, seed, size)
                {
                    spawn = new Vector2Int(PlayerPrefs.GetInt($"challenge.spawn.x"), PlayerPrefs.GetInt($"challenge.spawn.y"))
                };
            }

            return(stats);
        }
        else
        {
            return(null);
        }
    }
Exemplo n.º 2
0
 public void ContinuePause()
 {
     TimeAttack.currentState     = TimeAttack.Load();
     FloorBehaviour.nextSettings = TimeAttack.currentState.currentStage;
     SceneController.lastSelect  = "TitleScene";
     controller.Scene("GameScene");
 }
Exemplo n.º 3
0
    public static void Save(TimeAttack stats)
    {
        if (stats != null)
        {
            PlayerPrefs.SetInt($"challenge.id", stats.id);
            PlayerPrefs.SetInt($"challenge.time", stats.time);
            PlayerPrefs.SetInt($"challenge.difficulty", stats.difficulty);
            PlayerPrefs.SetInt($"challenge.cleared", stats.clearedCount);
            PlayerPrefs.SetInt($"challenge.seed", stats.seed);
            PlayerPrefs.SetFloat($"challenge.totalTime", stats.totalTime);
            PlayerPrefs.SetInt($"challenge.totalCoin", stats.totalCoin);
            PlayerPrefs.SetInt($"challenge.totalMiss", stats.totalMiss);

            if (stats.currentStage != null)
            {
                PlayerPrefs.SetInt($"challenge.stage.id", stats.currentStage.Value.id);
                PlayerPrefs.SetInt($"challenge.stage.size.x", stats.currentStage.Value.size.x);
                PlayerPrefs.SetInt($"challenge.stage.size.y", stats.currentStage.Value.size.y);
                PlayerPrefs.SetInt($"challenge.seed", stats.currentStage.Value.seed);
                PlayerPrefs.SetInt($"challenge.spawn.x", stats.currentStage.Value.spawn.x);
                PlayerPrefs.SetInt($"challenge.spawn.y", stats.currentStage.Value.spawn.y);
            }
            else
            {
                PlayerPrefs.DeleteKey($"challenge.stage.id");
            }
        }
        else
        {
            PlayerPrefs.DeleteKey($"challenge.id");
        }
        PlayerPrefs.Save();
    }
Exemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     if (coinsOnMap == 0)
     {
         TimeAttack script = (TimeAttack)gameObject.GetComponent(typeof(TimeAttack));
         script.Finish();
     }
 }
Exemplo n.º 5
0
 public void SetTime(int time)
 {
     if (TimeAttack.currentState == null)
     {
         TimeAttack.currentState = new TimeAttack();
     }
     TimeAttack.currentState.time = time;
     TimeAttack.Save(TimeAttack.currentState);
 }
Exemplo n.º 6
0
 public void SetDifficulty(int difficulty)
 {
     if (TimeAttack.currentState == null)
     {
         TimeAttack.currentState = new TimeAttack();
     }
     TimeAttack.currentState.difficulty = difficulty;
     TimeAttack.Save(TimeAttack.currentState);
 }
Exemplo n.º 7
0
    public void ApplyChallenge()
    {
        var rnd      = new System.Random(TimeAttack.currentState.seed);
        int sizebase = 4;
        int sizeex   = TimeAttack.currentState.difficulty * 8 + TimeAttack.currentState.clearedCount;

        TimeAttack.currentState.currentStage =
            new FloorSettings(TimeAttack.currentState.id, TimeAttack.currentState.seed, new Vector2Int(sizebase + rnd.Next(0, sizeex), sizebase + rnd.Next(0, sizeex)));

        TimeAttack.Save(TimeAttack.currentState);
        ContinuePause();
    }
Exemplo n.º 8
0
    // Use this for initialization
    void Start()
    {
        //Tag PlaneのGameObjectにdairotationスクリプトをコンポーネント
        var dia = GameObject.FindGameObjectWithTag("Plane");

        dia1 = dia.GetComponent <dairotation1>();

        var Taobj = GameObject.Find("TimeAttack");

        TAtext = Taobj.GetComponent <TimeAttack>();
        rig    = GetComponent <Rigidbody>();
    }
Exemplo n.º 9
0
 public TimeAttack(TimeAttack stats)
 {
     this.id           = stats.id;
     this.time         = stats.time;
     this.difficulty   = stats.difficulty;
     this.clearedCount = stats.clearedCount;
     this.seed         = stats.seed;
     this.totalTime    = stats.totalTime;
     this.totalCoin    = stats.totalCoin;
     this.totalMiss    = stats.totalMiss;
     this.currentStage = stats.currentStage;
 }
Exemplo n.º 10
0
    public void StartGame0(int id)
    {
        TimeAttack.Reset();
        TimeAttack.Save(TimeAttack.currentState);

        System.Random rnd      = new System.Random(id);
        int           sizebase = 4;
        int           sizeex   = (id % 8) * (id / 8) / 2;

        FloorBehaviour.nextSettings = new FloorSettings(id, id, new Vector2Int(sizebase + rnd.Next(0, sizeex), sizebase + rnd.Next(0, sizeex)));
        Scene("GameScene");
    }
Exemplo n.º 11
0
        public void SetUp()
        {
            time = new GameObject().AddComponent <TimeAttack>();
            life = new GameObject().AddComponent <LifeGauge>();
            var text = new GameObject().AddComponent <Text>();

            text.text = "Time Attack: {0:F2}";

            life.life    = 100;
            life.lifebar = new GameObject().AddComponent <Slider>();
            life.loose   = new GameObject().AddComponent <Text>();

            time.lifeGauge = life;
            time.text      = text;
        }
Exemplo n.º 12
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            GameObject bullet = Instantiate(prefab) as GameObject;
            bullet.transform.position = transform.position + Camera.main.transform.forward * 2;
            Rigidbody rb = bullet.GetComponent <Rigidbody>();
            rb.velocity = Camera.main.transform.forward * 40;
            Destroy(bullet, 5);
        }

        if (enemyOnMap == 0)
        {
            TimeAttack script = (TimeAttack)gameObject.GetComponent(typeof(TimeAttack));
            script.Finish();
        }
    }
Exemplo n.º 13
0
    public void Next()
    {
        if (TimeAttack.currentState == null)
        {
            return;
        }

        {
            TimeAttack.currentState.totalCoin += GameStats.currentStats.coin;
            TimeAttack.currentState.totalTime += GameStats.currentStats.time;
            TimeAttack.currentState.totalMiss += GameStats.currentStats.miss;
            TimeAttack.currentState.clearedCount++;
            TimeAttack.currentState.seed++;
            TimeAttack.Save(TimeAttack.currentState);
        }

        GameStats.Reset();
        ApplyChallenge();
    }
Exemplo n.º 14
0
    public void StartChallenge()
    {
        if (TimeAttack.currentState == null)
        {
            TimeAttack.currentState = new TimeAttack();
        }

        {
            TimeAttack.currentState.id           = TimeAttack.currentState.difficulty * 1000 + TimeAttack.currentState.time + 100000;
            TimeAttack.currentState.totalTime    = 0;
            TimeAttack.currentState.totalCoin    = 0;
            TimeAttack.currentState.totalMiss    = 0;
            TimeAttack.currentState.clearedCount = 0;
            TimeAttack.currentState.seed         = new System.Random().Next();
            TimeAttack.Save(TimeAttack.currentState);
        }

        SceneController.lastSelect = "TitleScene";

        GameStats.Reset();
        ApplyChallenge();
    }
Exemplo n.º 15
0
 private void Start()
 {
     TimeAttack.currentState = TimeAttack.Load();
 }
Exemplo n.º 16
0
 public static void Reset()
 {
     currentState = null;
 }
Exemplo n.º 17
0
    //----- Time attack
    public GameProperties GetTimeAttackProperties()
    {
        TimeAttack tm            = GameManager.Instance.GameMode as TimeAttack;
        int        size          = tm.CurrentStage + 2;
        Density    onePointers   = new Density();
        Density    twoPointers   = new Density();
        Density    blackHoles    = new Density();
        Count      multipliers2X = new Count();
        Count      multipliers3X = new Count();

        switch (tm.Dificulty)
        {
        case Dificulty.VeryEasy:
            #region VeryEasy
            blackHoles  = Density.High;
            onePointers = Density.Low;
            twoPointers = Density.None;

            if (size == 3)
            {
                multipliers2X = Count.None;
                multipliers3X = Count.None;
            }
            else if (size < 5)
            {
                multipliers2X = Count.None;
                multipliers3X = Count.None;
            }
            else if (size < 7)
            {
                multipliers2X = Count.None;
                multipliers3X = Count.None;
            }
            else
            {
                multipliers2X = Count.None;
                multipliers3X = Count.None;
            }
            #endregion
            break;

        case Dificulty.Easy:
            #region Easy
            blackHoles  = Density.High;
            onePointers = Density.Medium;
            twoPointers = Density.Low;

            if (size == 3)
            {
                multipliers2X = Count.None;
                multipliers3X = Count.None;
            }
            else if (size < 5)
            {
                multipliers2X = Count.None;
                multipliers3X = Count.None;
            }
            else if (size < 7)
            {
                multipliers2X = Count.None;
                multipliers3X = Count.None;
            }
            else
            {
                multipliers2X = Count.One;
                multipliers3X = Count.None;
            }
            #endregion
            break;

        case Dificulty.Medium:
            #region Medium
            blackHoles  = Density.Medium;
            onePointers = Density.Medium;
            twoPointers = Density.Medium;

            if (size == 3)
            {
                multipliers2X = Count.None;
                multipliers3X = Count.None;
            }
            else if (size < 5)
            {
                multipliers2X = Count.None;
                multipliers3X = Count.None;
            }
            else if (size < 7)
            {
                multipliers2X = Count.One;
                multipliers3X = Count.None;
            }
            else
            {
                multipliers2X = Count.One;
                multipliers3X = Count.One;
            }
            #endregion
            break;

        case Dificulty.Hard:
            #region Hard
            blackHoles  = Density.Low;
            onePointers = Density.High;
            twoPointers = Density.Medium;

            if (size == 3)
            {
                multipliers2X = Count.None;
                multipliers3X = Count.None;
            }
            else if (size < 5)
            {
                multipliers2X = Count.One;
                multipliers3X = Count.One;
            }
            else if (size < 7)
            {
                multipliers2X = Count.Two;
                multipliers3X = Count.Two;
            }
            else
            {
                multipliers2X = Count.Two;
                multipliers3X = Count.Two;
            }
            #endregion
            break;

        case Dificulty.VeryHard:
            #region VeryHard
            blackHoles  = Density.None;
            onePointers = Density.High;
            twoPointers = Density.High;

            if (size == 3)
            {
                multipliers2X = Count.One;
                multipliers3X = Count.None;
            }
            else if (size < 5)
            {
                multipliers2X = Count.Two;
                multipliers3X = Count.Two;
            }
            else if (size < 7)
            {
                multipliers2X = Count.Three;
                multipliers3X = Count.Three;
            }
            else
            {
                multipliers2X = Count.Four;
                multipliers3X = Count.Four;
            }
            #endregion
            break;

        default:
            break;
        }

        GameProperties go = new GameProperties
        {
            SizeX         = size,
            SizeY         = size,
            OnePointers   = onePointers,
            TwoPointers   = twoPointers,
            BlackHoles    = blackHoles,
            Multipliers2X = multipliers2X,
            Multipliers3X = multipliers3X
        };

        return(go);
    }
Exemplo n.º 18
0
 // Use this for initialization
 void Start()
 {
     timeAttack = GetComponent <TimeAttack>();
     Manager    = StageManager.Instance;
 }