コード例 #1
0
 public void Initialize()
 {
     levelTxt        = RootSystem.cfg.level.GetComponent <Text>();
     levelTxt.text   = "Level: " + VUtils.getInstance().getLevel();
     xpBar           = RootSystem.cfg.xpBar.GetComponent <RectTransform>();
     xpBar.sizeDelta = new Vector2(LevelLogic.getXPPercentage(game.experience) * 2, 22);
 }
コード例 #2
0
 public void Execute()
 {
     xpBar.sizeDelta = new Vector2(
         Mathf.Lerp(xpBar.sizeDelta.x,
                    (float)game.experience.xp / LevelLogic.getXPNeeded(game.experience.level) * 400,
                    5 * Time.deltaTime),
         22);
     levelTxt.text = "" + game.experience.level;
 }
コード例 #3
0
        protected override void Execute(List <InputEntity> entities)
        {
            if (!RootSystem.cfg.isPaused)
            {
                Config cfg = RootSystem.cfg;
                cfg.player.GetComponent <Animator>().Play("fall");
                RootSystem.cfg.isPaused = true;
                game.isDead             = true;
                LevelLogic.addXP(game.score.currScore, game.experience);
                RootSystem.cfg.gameOverMenu.AddComponent <FadeIn>();
                RootSystem.cfg.levelBar.AddComponent <FadeIn>();
                if (game.score.currScore > game.score.highscore)
                {
                    game.score.highscore = game.score.currScore;
                }
                VUtils.getInstance().save(game.experience.level, game.experience.xp, game.score.highscore);

                RootSystem.cfg.endScore.GetComponent <Text>().text =
                    "highscore: " + game.score.highscore + "\n" +
                    game.score.currScore;
                RootSystem.cfg.gamemenu.AddComponent <FadeOut>();
                GameObject lowerPart = entities[0].playerCollision.other.transform.GetChild(0).gameObject;
                GameObject upperPart = entities[0].playerCollision.other.transform.GetChild(1).gameObject;
                Transform  parent    = lowerPart.transform.parent;
                upperPart.transform.parent = parent.parent;
                lowerPart.transform.parent = parent.parent;
                Object.Destroy(parent.gameObject);
                GameObject go = new GameObject();
                go.AddComponent <BoxCollider>();
                go.transform.position = lowerPart.transform.position;
                upperPart.AddComponent <CapsuleCollider>().radius = 1;
                upperPart.AddComponent <Rigidbody>().AddForce(new Vector3(0, 0, -2 * game.speed.value), ForceMode.Impulse);
                Object.Destroy(go, 0.5f);
                Object.Destroy(upperPart, 2f);
                game.speed.value = 0;
            }
            else
            {
                Debug.Log("deleting obstacle because the player was there first");
                entities[0].playerCollision.other.DestroyGameObject();
            }
            foreach (var entity in entities)
            {
                entity.Destroy();
            }
        }