void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Player"))
     {
         PlayerInfo playerInfo = other.GetComponent <PlayerInfo> ();
         playerInfo.AddExp();
         Destroy(gameObject);
     }
 }
Beispiel #2
0
    public void ApplyRewardToPlayers()
    {
        foreach (var player in PlayerManager.Instance.Players)
        {
            PlayerInfo   info   = player.Value.info;
            PlayerRecord record = m_RecordMap[player.Key];

            info.AddExp(record.Exp);
            info.AddMoney(record.Money);

            MissionReward missionReward = CaculateAllMissionReward();
            info.AddExp(missionReward.EXP);
            info.AddMoney(missionReward.Money);

            PlayerManager.Instance.SavePlayerInfo(player.Key);
        }

        Destroy(this.gameObject);
    }
    public PlayerInfo LoadPlayerInfo(DataSaver data)
    {
        PlayerInfo player = new PlayerInfo();

        player.SetUsername(data.Username);
        player.AddExp(data.Exp);
        player.AddMoney(data.Money);
        player.RefreshEquipWeapon(data.Weapons);
        player.RefreshEquipStratagem(data.Stratagems);
        player.RefreshEquipGrenade(data.Grenades);
        player.RefreshUnlockedWeapons(data.UnlockedWeapons);
        player.RefreshUnlockedStratagems(data.UnlockedStratagems);

        return(player);
    }
Beispiel #4
0
    public void TakeDamage(int damage)
    {
        if (hp <= 0)
        {
            return;
        }
        attackTarget = GameObject.FindGameObjectWithTag(Tags.player).transform;
        //如果角色血没了,目标设为空;
        if (attackTarget.GetComponent <PlayerInfo>().current_hp <= 0)
        {
            attackTarget = null;
        }

        // Debug.Log("tar=" + attackTarget.name);
        state = EnemyState.attack1;
        float v = Random.Range(0, 1.0f);

        if (v < misValue)
        {
            // HUDText.Add("Miss", Color.red, 1);
        }
        else
        {
            //state = EnemyState.hit;
            this.hp -= damage;
            AudioSource.PlayClipAtPoint(hit_click, transform.position);
            // particle.Play();
            if (hp <= 0)
            {
                //掉落装备
                //Random.RandomRange(0, 20);
                int id = Random.Range(0, 50);
                //如果随机的数字可以获取到装备
                if (ItemDataBase._instance.GetInfoById(id) != null)
                {
                    go = Instantiate(anyPrefabs, new Vector3(transform.position.x, transform.position.y + 2, transform.position.z), Quaternion.identity);
                    go.GetComponent <AnyIndex>().id         = ItemDataBase._instance.GetInfoById(id).id;
                    go.GetComponentInChildren <Text>().text = ItemDataBase._instance.GetInfoById(id).name;
                }
                playerInfo.AddExp(exp);
                state = EnemyState.death;
                GameObject.Find("EnemyBirthPlace").GetComponent <SmallEnemyBirth>().currentNum--;
                BarNPC._instance.KillMonster();
                BarNPC._instance.ShowTasking();
                StartCoroutine(Timer());
            }
        }
    }