Exemplo n.º 1
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Exemplo n.º 2
0
 public static void PlayerLevelChanged(PlayerLevel playerLevel)
 {
     if (OnPlayerLevelChange != null)
     {
         OnPlayerLevelChange(playerLevel);
     }
 }
Exemplo n.º 3
0
    void Start()
    {
        playerHealth = GameObject.Find("Player").GetComponent <PlayerHealth>();
        playerLevel  = GameObject.Find("Player").GetComponent <PlayerLevel>();
        if (player == null)
        {
            player = GameObject.Find("Player").GetComponent <Player>();
        }
        if (healthSlider == null)
        {
            healthSlider = GameObject.Find("CanvasPlayerInterface/DefaultUI/HitPoints/HitPointsBar").GetComponent <Slider>();
        }
        if (healthSliderText == null)
        {
            healthSliderText = GameObject.Find("CanvasPlayerInterface/DefaultUI/HitPoints/HitPointUI").GetComponent <Text>();
        }
        if (levelSlider == null)
        {
            levelSlider = GameObject.Find("CanvasPlayerInterface/DefaultUI/Experience/ExperienceBar").GetComponent <Slider>();
        }
        if (levelSliderText == null)
        {
            levelSliderText = GameObject.Find("CanvasPlayerInterface/DefaultUI/Experience/ExperienceUI").GetComponent <Text>();
        }
        if (levelText == null)
        {
            levelText = GameObject.Find("CanvasPlayerInterface/DefaultUI/Level/Text").GetComponent <Text>();
        }

        UIEventHandler.OnPlayerHealthChanged += UpdateHealth;
        UIEventHandler.OnPlayerLevelChanged  += UpdateLevel;
    }
Exemplo n.º 4
0
        private PlayerLevel getPlayerFromLevelData(Player player)
        {
            if (player == null)
            {
                return(null);
            }

            //return existing player
            foreach (PlayerLevel playerLevel in _PlayerLevelData)
            {
                if (playerLevel.playerId == player.Id)
                {
                    Log("getPlayerFromLevel: " + player.Id + " - result: " + playerLevel);
                    return(playerLevel);
                }
            }

            // Create new players in level system
            PlayerLevel newPlayerLevel = new PlayerLevel(player.Id, player.Name);

            Log("getPlayerFromLevel: " + player.Id + " - result: new player created: " + newPlayerLevel);
            _PlayerLevelData.Add(newPlayerLevel);
            SaveData();
            return(newPlayerLevel);
        }
Exemplo n.º 5
0
    //this function subtracts damage to update the currentHP
    //it also returns either true or false depending on if the unit has died

    void Start()
    {
        global = GameObject.Find("GlobalObject");
        GlobalControl globalObject = global.GetComponent <GlobalControl> ();

        playerLevel = gameObject.GetComponent <PlayerLevel> ();
    }
Exemplo n.º 6
0
        private string getPlayerFormat(PlayerLevel playerLevel)
        {
            playerLevel = updatePlayerLevel(playerLevel);
            Player player = getPlayerFromPlayerLevel(playerLevel);

            if (player == null)
            {
                return(null);
            }

            Log("Set player format for: " + player.Name + " playerLevel: " + playerLevel);
            string format = "";

            if (playerLevel != null)
            {
                format = string.Format("{0} ([00cc00]{1}[ffffff])", player.Name, playerLevel.currentLevel);
            }
            else
            {
                format = string.Format("{0} ([00cc00]0[ffffff])", player.Name);
            }

            if (player.HasPermission("admin"))
            {
                format = string.Format("[4da6ff]Admin[ffffff] | {0}", format);
            }
            Log("getPlayerFormat for: playerLevel: " + playerLevel + " - result: " + format);
            return(format);
        }
Exemplo n.º 7
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (PlayerLevel != 0)
            {
                hash ^= PlayerLevel.GetHashCode();
            }
            if (WarningSeverity.Length != 0)
            {
                hash ^= WarningSeverity.GetHashCode();
            }
            if (WeatherTag.Length != 0)
            {
                hash ^= WeatherTag.GetHashCode();
            }
            if (MoonTag.Length != 0)
            {
                hash ^= MoonTag.GetHashCode();
            }
            if (TimeOfDayTag.Length != 0)
            {
                hash ^= TimeOfDayTag.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        public List <PlayerLevel> GetAllPlayersLevels()
        {
            List <PlayerLevel> playersLevels = new List <PlayerLevel>();

            try
            {
                using (SqlConnection conn = _dbConnection.GetConnString())
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("SELECT playerLevel, COUNT(playerLevel) AS AmountPlayers " +
                                                           "FROM Player " +
                                                           "GROUP BY playerLevel", conn))
                    {
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                PlayerLevel playerLevel = new PlayerLevel
                                {
                                    Level         = (int)reader["playerLevel"],
                                    AmountPlayers = (int)reader["AmountPlayers"]
                                };
                                playersLevels.Add(playerLevel);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
            return(playersLevels);
        }
Exemplo n.º 9
0
 private void Awake()
 {
     PlayerLevel    = GetComponent <PlayerLevel>();
     CurrentHealth  = MaxHealth;
     CharacterStats = new CharacterStats(10, 10, 10);
     UIEventHandler.HealthChanged(MaxHealth, CurrentHealth);
 }
Exemplo n.º 10
0
 // Start is called before the first frame update
 void Start()
 {
     Player          = GameObject.Find("Player");
     Playerlevel     = Player.GetComponent <PlayerLevel>();
     ContainerObject = GameObject.Find("ContainerObject");
     ContainerBox    = ContainerObject.GetComponent <SpriteRenderer>();
 }
Exemplo n.º 11
0
    private void OnPlayerXPUpdated()
    {
        PlayerLevel playerLevel = GameLogic.GetInstance().GetPlayer().level;

        xpText.text     = playerLevel.xp + "/" + playerLevel.xpRequired + " XP";
        xpBar.anchorMax = new Vector2((float)playerLevel.xp / playerLevel.xpRequired, 1f);
    }
Exemplo n.º 12
0
    public void Load()
    {
        Debug.Log(Application.persistentDataPath);
        if (File.Exists(Application.persistentDataPath + "/playerInfo.dat"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/playerInfo.dat", FileMode.Open);
            PlayerData      data = (PlayerData)bf.Deserialize(file);

            currentScene = data.currentScene;
            //health = data.health;
            //energy = data.energy;
            //exp = data.exp;


            file.Close();

            SceneManager.LoadScene(currentScene, LoadSceneMode.Single);
            healthScript = gameObject.GetComponent <PlayerHealth>();
            energyScript = gameObject.GetComponent <PlayerEnergy>();
            levelScript  = gameObject.GetComponent <PlayerLevel>();
            healthScript.currentHealth = data.health;
            energyScript.currentEnergy = data.energy;
            levelScript.exp            = data.exp;
            levelScript.level          = data.level;
        }
        Debug.Log("Loading");
    }
Exemplo n.º 13
0
    private void SetLevel(bool isNotInitial)
    {
        GlobalSettings._playerLevel = _levelIndex;
        PlayerLevel playerLevel = _levelStats.PlayerLevel[_levelIndex];

        _expCap       = playerLevel.LevelCap;
        _currentLevel = playerLevel.Level;
        _playerUI.StatsUI.LevelUp(_currentLevel, _expCap, isNotInitial, playerLevel.perk);

        if (_currentLevel < _levelStats.MaxLevel)
        {
            if (isNotInitial)
            {
                _currentExp = _reservedExp;
                GlobalSettings._playerExp = _currentExp;
            }
        }
        else
        {
            _currentExp = 0;
        }
        _playerUI.StatsUI.SetExp(_currentExp);

        _player.SetHealth(playerLevel.Hearts, isNotInitial);
        _player.SetAttack(playerLevel.Attack);
        _levelIndex++;
    }
Exemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     PlayerLevel         = GetComponent <PlayerLevel>();
     playerCurrentHealth = playerMaxHealth;
     spriteRenderer      = gameObject.GetComponent <SpriteRenderer>();
     cCol = gameObject.GetComponent <CapsuleCollider2D>();
 }
    // Use this for initialization
    void Awake()
    {
        Instance      = this;
        shootFireBall = GetComponentInChildren <ShootFireBall> ();

        playerHealth   = GetComponent <PlayerHealth> ();
        playerMana     = GetComponent <PlayerMana> ();
        playerMovement = GetComponent <PlayerMovement> ();
        orbControl     = GetComponentInChildren <OrbControl> ();
        skill1Text     = Skill1.GetComponentsInChildren <Text> ();
        skill2Text     = Skill2.GetComponentsInChildren <Text> ();
        skill3Text     = Skill3.GetComponentsInChildren <Text> ();
        skill1Image    = Skill1.GetComponentInChildren <Image> ();
        skill2Image    = Skill2.GetComponentInChildren <Image> ();
        skill3Image    = Skill3.GetComponentInChildren <Image> ();
        skill1Button   = Skill1.GetComponent <Button> ();
        skill2Button   = Skill2.GetComponent <Button> ();
        skill3Button   = Skill3.GetComponent <Button> ();

        skillValues.Add(new KeyValuePair <string, int> ("Explosion Size", 1));
        skillValues.Add(new KeyValuePair <string, int> ("FireBolt Damage", 1));
        skillValues.Add(new KeyValuePair <string, int> ("FireBall", 0));
        skillValues.Add(new KeyValuePair <string, int> ("Health Up", 1));
        skillValues.Add(new KeyValuePair <string, int> ("Mana Up", 1));
        skillValues.Add(new KeyValuePair <string, int> ("Mana Recovery Rate", 1));
        skillValues.Add(new KeyValuePair <string, int> ("Walking Speed", 1));

        skillText = new string[] { "Radius +0.5 \r\nMana Cost +0.1", "SpellDamage +10 \r\nManaCost +0.2",
                                   "New Skill: FireBall\r\nPress 1 to use", "Max Health +20", "Max Mana +20", "Recovery Rate +0.2", "Speed +0.2" };

        eventAdded   = false;
        currentLevel = 1;
    }
Exemplo n.º 16
0
        public Player(Coord position)
            : base(Color.White, Color.Black, '@', "Player", position, (int)MapLayer.PLAYER, isWalkable: false,
                   isTransparent: true)
        {
            FOVRadius = 10;

            var stats = new Stats();

            stats[StatTypes.STRENGTH]  = 30;
            stats[StatTypes.MAGIC]     = 10;
            stats[StatTypes.DEXTERITY] = 20;
            stats[StatTypes.VITALITY]  = 25;
            stats[StatTypes.MAX_LIFE]  = 70;
            stats[StatTypes.LIFE]      = 50;
            stats[StatTypes.MAX_MANA]  = 10;
            stats[StatTypes.MANA]      = 0;
            stats[StatTypes.LGOL]      = 2;
            stats[StatTypes.MGOL]      = 1;
            AddGoRogueComponent(stats);

            var playerInventory = new Inventory();

            AddGoRogueComponent(playerInventory);
            playerInventory.AddItem(new HealthPotion(10));
            playerInventory.AddItem(new ManaPotion(5));
            playerInventory.AddItem(new Cap());
            playerInventory.AddItem(new SkullCap());
            playerInventory.AddItem(new SmallAxe());
            playerInventory.AddItem(new SmallAxe());

            var playerLevel = new PlayerLevel();

            AddGoRogueComponent(playerLevel);
            playerLevel.Init(1);
        }
Exemplo n.º 17
0
	public static void Create (Action done)
	{
		const string section = "PTestPlaytomic.PlayerLevels.Create";
		Debug.Log(section);
		
		var level = new PlayerLevel {
				name = "create level" + rnd,
				playername = "ben" + rnd,
				playerid = "0",
				data = "this is the level data",
				fields = new Dictionary<string,object> {
					{"rnd", rnd}
				}
			};
			
		Playtomic.PlayerLevels.Save (level, (l, r) => {			
			l = l ?? new PlayerLevel ();
			AssertTrue (section + "#1", "Request succeeded", r.success);
			AssertEquals (section + "#1", "No errorcode", r.errorcode, 0);
			AssertTrue (section + "#1", "Returned level is not null", l.Keys.Count > 0);
			AssertTrue (section + "#1", "Returned level has levelid", l.ContainsKey ("levelid"));
			AssertEquals (section + "#1", "Level names match", level.name, l.name); 

			Playtomic.PlayerLevels.Save (level, (l2, r2) => {
				AssertTrue (section + "#2", "Request succeeded", r2.success);
				AssertEquals (section + "#2", "Duplicate level errorcode", r2.errorcode, 405);
				done ();
			});
		});
	}
        public override int GetHashCode()
        {
            int hash = 1;

            if (PlayerLevel != 0)
            {
                hash ^= PlayerLevel.GetHashCode();
            }
            if (EncounterId.Length != 0)
            {
                hash ^= EncounterId.GetHashCode();
            }
            if (SpellId.Length != 0)
            {
                hash ^= SpellId.GetHashCode();
            }
            if (Outcome != 0)
            {
                hash ^= Outcome.GetHashCode();
            }
            if (CheckpointFailRound != 0)
            {
                hash ^= CheckpointFailRound.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 19
0
        private string _GetActionName(PlayerLevel level, int id)
        {
            var name = string.Empty;

            switch (level)
            {
            case PlayerLevel.Outer:
            {
                var template = MetadataManager.Instance.GetTemplate <StageOuterPoint>(id);
                if (null != template)
                {
                    name = template.action;
                }
            }
            break;

            case PlayerLevel.Inner:
            {
                var template = MetadataManager.Instance.GetTemplate <StageInnerPoint>(id);
                if (null != template)
                {
                    name = template.action;
                }
            }
            break;

            default:
                Console.Error.WriteLine("[SelectState _GetActionName] the player do not in inner or outer");
                break;
            }

            return(name);
        }
Exemplo n.º 20
0
        private int _PointsCount(PlayerLevel level)
        {
            var count = 0;

            switch (level)
            {
            case PlayerLevel.Outer:
            {
                var metadata = MetadataManager.Instance.GetTemplateTable <StageOuterPoint>();
                if (null != metadata)
                {
                    count = metadata.Count;
                }
            }
            break;

            case PlayerLevel.Inner:
            {
                var metadata = MetadataManager.Instance.GetTemplateTable <StageInnerPoint>();
                if (null != metadata)
                {
                    count = metadata.Count;
                }
            }
            break;

            default:
                Console.Error.WriteLine("[SelectState _PointsCount] the player do not in inner or outer");
                break;
            }

            return(count);
        }
Exemplo n.º 21
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (EncounterId.Length != 0)
            {
                hash ^= EncounterId.GetHashCode();
            }
            if (AttemptNumber != 0)
            {
                hash ^= AttemptNumber.GetHashCode();
            }
            if (PlayerLevel != 0)
            {
                hash ^= PlayerLevel.GetHashCode();
            }
            if (EncounterProtoId.Length != 0)
            {
                hash ^= EncounterProtoId.GetHashCode();
            }
            if (SpellPattern.Length != 0)
            {
                hash ^= SpellPattern.GetHashCode();
            }
            if (ArMode != 0)
            {
                hash ^= ArMode.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 22
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        GUILayout.Label("Each level adds _add exp per lvl_ to _experience to the next lvl_.");

        GUILayout.Label("if(level % lvlDifficultyDenominator == 0)  addExpPerLvl *= difficultyMultiplier ");

        PlayerLevel plvl = (PlayerLevel)target;

        if (GUILayout.Button("ADD 15 exp"))
        {
            plvl.AddExperience(15);
        }

        if (GUILayout.Button("ADD 100 exp"))
        {
            plvl.AddExperience(100);
        }

        if (GUILayout.Button("ADD 300 exp"))
        {
            plvl.AddExperience(300);
        }
    }
Exemplo n.º 23
0
    private void Populate()
    {
        GameLogic   game        = GameLogic.GetInstance();
        PlayerLevel playerLevel = game.player.level;

        attributeText.text = "Attributes: " + playerLevel.unusedAttributes;
        perkText.text      = "Perks: " + playerLevel.unusedPerks;

        strengthText.text     = playerLevel.strength.ToString();
        dexterityText.text    = playerLevel.dexterity.ToString();
        constitutionText.text = playerLevel.constitution.ToString();
        intelligenceText.text = playerLevel.intelligence.ToString();
        wisdomText.text       = playerLevel.wisdom.ToString();
        charismaText.text     = playerLevel.charisma.ToString();

        bool hasUnusedAttributes = playerLevel.unusedAttributes > 0;

        foreach (GameObject button in addAttributeButtons)
        {
            button.SetActive(hasUnusedAttributes);
        }
        if (abilityTreeBuilt)
        {
            abilityTree.Populate();
        }
        else
        {
            abilityTree.BuildAbilityTree(playerLevel.abilityTree);
            abilityTreeBuilt = true;
        }
    }
Exemplo n.º 24
0
 void OnEnable()
 {
     playerLevel    = gameObject.GetComponent <PlayerLevel>();
     energyBar      = GameObject.FindGameObjectWithTag("Energy");
     energyBarTrans = energyBar.GetComponent <RectTransform>();
     level          = playerLevel.getLevel();
 }
Exemplo n.º 25
0
 void Start()
 {
     inventory = GetComponent <Inventory>();
     player    = GetComponent <Player>();
     hpPot     = GetComponent <HealthPotions>();
     level     = GetComponent <PlayerLevel>();
 }
Exemplo n.º 26
0
 void Start()
 {
     PlayerLevel        = GetComponent <PlayerLevel>();
     this.currentHealth = this.maxHealth;
     characterStats     = new CharacterStats(10, 10, 10);
     //UIEventHandler.HealthChanged(this.currentHealth, this.maxHealth);
 }
Exemplo n.º 27
0
    public static void Load(Action done)
    {
        const string section = "TestPlaytomic.PlayerLevels.Load";

        Debug.Log(section);

        var level = new PlayerLevel {
            name       = "sample loading level " + rnd,
            playername = "ben" + rnd,
            playerid   = rnd.ToString(CultureInfo.InvariantCulture),
            data       = "this is the level data",
            fields     = new Dictionary <string, object> {
                { "rnd", rnd }
            }
        };

        Playtomic.PlayerLevels.Save(level, (l, r) => {
            AssertTrue(section + "#1", "Request succeeded", r.success);
            AssertEquals(section + "#1", "No errorcode", r.errorcode, 0);
            AssertTrue(section + "#1", "Name is correct", l.ContainsKey("levelid"));
            AssertEquals(section + "#1", "Name is correct", level.name, l.name);
            AssertEquals(section + "#1", "Data is correct", level.data, l.data);

            Playtomic.PlayerLevels.Load(l.levelid, (l2, r2) => {
                AssertTrue(section, "Request succeeded", r2.success);
                AssertEquals(section, "No errorcode", r2.errorcode, 0);
                AssertEquals(section, "Name is correct", level.name, l2.name);
                AssertEquals(section, "Data is correct", level.data, l2.data);
                done();
            });
        });
    }
Exemplo n.º 28
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (PlayerLevel != 0)
            {
                hash ^= PlayerLevel.GetHashCode();
            }
            if (EncounterId.Length != 0)
            {
                hash ^= EncounterId.GetHashCode();
            }
            if (NodeLocation.Length != 0)
            {
                hash ^= NodeLocation.GetHashCode();
            }
            if (Outcome != 0)
            {
                hash ^= Outcome.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 29
0
    public static void Create(Action done)
    {
        const string section = "PTestPlaytomic.PlayerLevels.Create";

        Debug.Log(section);

        var level = new PlayerLevel {
            name       = "create level" + rnd,
            playername = "ben" + rnd,
            playerid   = "0",
            data       = "this is the level data",
            fields     = new Dictionary <string, object> {
                { "rnd", rnd }
            }
        };

        Playtomic.PlayerLevels.Save(level, (l, r) => {
            l = l ?? new PlayerLevel();
            AssertTrue(section + "#1", "Request succeeded", r.success);
            AssertEquals(section + "#1", "No errorcode", r.errorcode, 0);
            AssertTrue(section + "#1", "Returned level is not null", l.Keys.Count > 0);
            AssertTrue(section + "#1", "Returned level has levelid", l.ContainsKey("levelid"));
            AssertEquals(section + "#1", "Level names match", level.name, l.name);

            Playtomic.PlayerLevels.Save(level, (l2, r2) => {
                AssertTrue(section + "#2", "Request succeeded", r2.success);
                AssertEquals(section + "#2", "Duplicate level errorcode", r2.errorcode, 405);
                done();
            });
        });
    }
Exemplo n.º 30
0
 public override void Awake()
 {
     characterHealth = GetComponent <CharacterHealth>();
     playerLevel     = GetComponent <PlayerLevel>();
     playerWeaponRangedController = GetComponentInChildren <PlayerWeaponRangedController>();
     playerWeaponMeleeController  = GetComponentInChildren <PlayerWeaponMeleeController>();
 }
Exemplo n.º 31
0
 void Awake()
 {
     playerHealth = GetComponent<PlayerHealth>();
     playerLevel = GetComponent<PlayerLevel>();
     playerPerks = GetComponent<PlayerPerks>();
     playerShooting = GetComponent<PlayerShooting>();
     playerMovement = GetComponent<PlayerMovement>();
 }
Exemplo n.º 32
0
    void Death(PlayerLevel player)
    {
        isDead = true;

        RpcDeath();
        capsuleCollider.isTrigger = true;

        killExperience.GiveExperience(player);
        dropManager.SpawnDrop(this.transform);
    }
Exemplo n.º 33
0
	void Awake() {
		// intialize player's attribute
		playerScore = GetComponent<PlayerScore> ();
		playerAttack = GetComponent<PlayerAttack> ();
		playerEnergy = GetComponent<PlayerEnergy> ();
		playerLevel = GetComponent<PlayerLevel> ();

		// other flag status
		grounded = false;
		facingLeft = true;
		doubleJump = false;

		source = GetComponent<AudioSource> ();
	}
Exemplo n.º 34
0
    public void TakeDamage(int amount, Vector3 hitPoint, PlayerLevel player)
    {
        if (isDead)
            return;

        currentHealth -= amount;

        RpcTakeDamage(amount, hitPoint);

        if (currentHealth <= 0)
        {
            Death(player);
        }
    }
Exemplo n.º 35
0
	private IEnumerator SendSaveLoadRequest(string section, string action, Dictionary<string,object> postdata, Action<PlayerLevel, PResponse> callback)
	{ 
		var www = PRequest.Prepare (section, action, postdata);
		yield return www;
		
		var response = PRequest.Process(www);
		PlayerLevel level = null;
		
		if (response.success)
		{
			level = new PlayerLevel((Dictionary<string,object>) response.json["level"]);
		}
		
		callback(level, response);
	}
Exemplo n.º 36
0
        public List<PlayerModel> GetAll(PlayerLevel level, string fullName = "", string city = "")
        {
            var players = _playerRepository.Table.Where(p => !p.Deleted).ToList();

            var models = players.Select(Mapper.Map<Player, PlayerModel>).ToList();

            if (level != PlayerLevel.All)
            {
                models = models.Where(p => p.Level == level).ToList();
            }

            if (!string.IsNullOrEmpty(fullName))
            {
                models = models.Where(p => p.FullName.Trim().ToLower().Contains(fullName.Trim().ToLower())).ToList();
            }

            if (!string.IsNullOrEmpty(city))
            {
                models = models.Where(p => p.City.Trim().ToLower().Contains(city.Trim().ToLower())).ToList();
            }

            return models;
        }
Exemplo n.º 37
0
	public static void Load (Action done)
	{
		const string section = "TestPlaytomic.PlayerLevels.Load";
		Debug.Log(section);
		
		var level = new PlayerLevel {
				name = "sample loading level " + rnd,
				playername = "ben" + rnd,
				playerid = rnd.ToString (CultureInfo.InvariantCulture),
				data = "this is the level data",
				fields = new Dictionary<string,object> {
					{"rnd", rnd}
				}
			};
			
		Playtomic.PlayerLevels.Save (level, (l, r) => {
			AssertTrue (section + "#1", "Request succeeded", r.success);
			AssertEquals (section + "#1", "No errorcode", r.errorcode, 0);
			AssertTrue (section + "#1", "Name is correct", l.ContainsKey ("levelid"));
			AssertEquals (section + "#1", "Name is correct", level.name, l.name);
			AssertEquals (section + "#1", "Data is correct", level.data, l.data);

			Playtomic.PlayerLevels.Load (l.levelid, (l2, r2) => {
				AssertTrue (section, "Request succeeded", r2.success);
				AssertEquals (section, "No errorcode", r2.errorcode, 0);
				AssertEquals (section, "Name is correct", level.name, l2.name);
				AssertEquals (section, "Data is correct", level.data, l2.data);
				done ();
			});
		});
	}
Exemplo n.º 38
0
	public static void Rate (Action done)
	{
		const string section = "TestPlaytomic.PlayerLevels.Rate";
		Debug.Log(section);
		
		var level = new PlayerLevel {
				name = "rate " + rnd,
				playername = "ben" + rnd,
				playerid = "0",
				data = "this is the level data",
				fields = new Dictionary<string,object> {
					{"rnd", rnd}
				}
			};
			
		Playtomic.PlayerLevels.Save (level, (l, r) => {
			
			l = l ?? new PlayerLevel ();
			AssertTrue (section + "#1", "Request succeeded", r.success);
			AssertEquals (section + "#1", "No errorcode", r.errorcode, 0);
			AssertTrue (section + "#1", "Returned level is not null", l.Keys.Count > 0);
			AssertTrue (section + "#1", "Returned level has levelid", l.ContainsKey ("levelid"));

			// invalid rating
			Playtomic.PlayerLevels.Rate (l.levelid, 70, r2 => {
				AssertFalse (section + "#2", "Request failed", r2.success);
				AssertEquals (section + "#2", "Invalid rating errorcode", r2.errorcode, 401);

				// valid rating
				Playtomic.PlayerLevels.Rate (l.levelid, 7, r3 => {

					AssertTrue (section + "#3", "Request succeeded", r3.success);
					AssertEquals (section + "#3", "No errrorcode", r3.errorcode, 0);

					// duplicate rating
					Playtomic.PlayerLevels.Rate (l.levelid, 6, r4 => {
						AssertFalse (section + "#4", "Request failed", r4.success);
						AssertEquals (section + "#4", "Already rated errorcode", r4.errorcode, 402);
						done ();
					});
				});
			});
		});
	}
Exemplo n.º 39
0
	/**
	 * Saves a PlayerLevel
	 * @param	level	PlayerLevel	The level
	 * @param	callback	Action<PlayerLevel, PResponse>	Callback function
	 */
	public void Save(PlayerLevel level, Action<PlayerLevel, PResponse> callback)
	{
		Playtomic.API.StartCoroutine(SendSaveLoadRequest(SECTION, SAVE, (Dictionary<string,object>) level, callback));
	}
Exemplo n.º 40
0
		void Awake()
		{
			playerLevel = GetComponent<PlayerLevel>();
		}
Exemplo n.º 41
0
        private async void ShowLevelUpAnimation(PlayerLevel newRank)
        {
            var title = string.Format("You have levelled up!");

            var dialog = new MessageDialog("New Ranking: " + newRank.ToString(), title);

            dialog.Commands.Add(new UICommand("OK"));

            await dialog.ShowAsync();
        }
Exemplo n.º 42
0
 public void GiveExperience(PlayerLevel player)
 {
     player.GetExperience(experience);
 }