Exemple #1
0
    public virtual void Die()
    {
        foreach (KeyValuePair <int, float> val in playerDamage)
        {
            float percentage = val.Value / maxHealth * 100;

            RandomLoot randomLoot;
            if (GameServer.clients[val.Key].player.group == null)
            {
                randomLoot = new RandomLoot((int)npc_type, percentage, max_loot_count);
                randomLoot.GenerateLoot();
            }
            else
            {
                float damage = GameServer.FindGroupDamage(this, GameServer.clients[val.Key].player.group);
                randomLoot = new RandomLoot((int)npc_type, percentage, max_loot_count);
                randomLoot.GenerateLoot();
            }

            StartCoroutine(GameServer.DespawnLoot(val.Key, randomLoot, NetworkManager.lootDespawnTime));

            if (!GameServer.playerLoot.ContainsKey(val.Key))
            {
                GameServer.playerLoot.Add(val.Key, new List <RandomLoot>());
            }
            GameServer.playerLoot[val.Key].Add(randomLoot);

            randomLoot.position = transform.position;
            ServerSend.OnLootDropped(val.Key, randomLoot.id, transform.position);
        }
        playerDamage.Clear();
    }
Exemple #2
0
 public static void RemoveLoot(int playerId, RandomLoot loot)
 {
     if (playerLoot.ContainsKey(playerId))
     {
         playerLoot[playerId].Remove(loot);
     }
 }
Exemple #3
0
    public static IEnumerator DespawnLoot(int playerId, RandomLoot loot, float timeLeft)
    {
        yield return(new WaitForSeconds(timeLeft));

        if (GameServer.playerLoot[playerId].Contains(loot))
        {
            GameServer.RemoveLoot(playerId, loot);
            ServerSend.RemoveLoot(playerId, loot.id);
        }
    }
    // General Cached References

    // Start is called before the first frame update
    void Start()
    {
        animator = GetComponent <Animator>();

        this.rb = this.GetComponent <Rigidbody2D>();

        target = GameObject.FindGameObjectWithTag(Slime_Const.Tag_Player).transform;
        //  lootDrop = GetComponent<LootDrop>();
        randomLoot    = GetComponent <RandomLoot>();
        currentHealth = maxHealth;
    }
    //public BoxCollider2D box1;
    //public BoxCollider2D box2;

    // Start is called before the first frame update
    void Start()
    {
        // Color
        nativeColor = GetComponent <SpriteRenderer>().color;
        damageColor = Color.red;

        gamemanager   = FindObjectOfType <GameManager>();
        target        = GameObject.FindGameObjectWithTag(Slime_Const.Tag_Player).transform;
        randomLoot    = GetComponent <RandomLoot>();
        this.rb       = this.GetComponent <Rigidbody2D>();
        currentHealth = maxHealth;          // verändet Wert der Healtbar
        healthBar.SetMaxHealth(maxHealth);
        healthBar.SetHealth(currentHealth);
    }
Exemple #6
0
        static void Main()
        {
            Console.OutputEncoding = Encoding.UTF8;

            var random = Rand.GetRandom();
            var logger = new ConsoleLogger
            {
                Take = LoggerSeverity.Error
            };

            var randomLoot = new RandomLoot <string, string>(random)
            {
                Logger = logger
            };
            var partition = new PartitionLoot <string, string>(random)
            {
                Logger = logger
            };
            var fpl = new FirstPickLoot <string, string>();


            LootTree <string, string> tree = new LootTree <string, string>(partition, logger);

            ILootable <string, string>[] convertPath(params string[] s)
            => s.Select(x =>
            {
                if (!x.Contains(':'))
                {
                    return(new DefaultLoot <string, string>(50, x, x));
                }

                var parts = x.Split(':');
                return(new DefaultLoot <string, string>(int.Parse(parts[1]), parts[0], parts[0]));
            })
            .ToArray();


            var bonusPath           = convertPath("Bonus:5");
            var defaultPath         = convertPath("Default:95");
            var genPath             = convertPath("Default", "Generation");
            var miscPath            = convertPath("Default", "Generation", "Useful", "Misc:70");
            var weaponPath          = convertPath("Default", "Generation", "Useful", "Gear:25", "Weapon:35");
            var legendaryWeaponPath = convertPath("Default", "Generation", "Useful", "Gear", "LegendaryWeapon:5");
            var armorPath           = convertPath("Default", "Generation", "Useful", "Gear", "Armor:60");
            var crapPath            = convertPath("Default", "Generation", "Crap");
            var legacyPath          = convertPath("LegacyGeneration:10");

            var prov = new LootProvider();

            var miscNode    = tree.AddPath(miscPath).AddRangeAsLeafs(prov.Misc);
            var crapNode    = tree.AddPath(crapPath).AddLeaf(prov.Crap);
            var defaultNode = tree.AddPath(defaultPath);

            var legacyHalfRoot = tree.AddHalfRoot("Legacy");
            var legacyNode     = tree
                                 .AddPath(legacyHalfRoot, legacyPath)
                                 .AddRangeAsLeafs(prov.Armor)
                                 .AddRangeAsLeafs(prov.Weapons)
                                 .AddLeaf(prov.LegendaryWeapon);

            var genNode    = tree.AddPath(genPath);
            var bonusNode  = tree.AddPath(bonusPath);
            var armorNode  = tree.AddPath(armorPath).AddRangeAsLeafs(prov.Armor);
            var weaponNode = tree.AddPath(weaponPath).AddRangeAsLeafs(prov.Weapons);
            var legyNode   = tree.AddPath(legendaryWeaponPath).AddLeaf(prov.LegendaryWeapon);

            NodeUpdateList <string, string> nodes = tree.AutoList;

            nodes.OnDetachedNodeRemoved += n => Console.WriteLine($"registered node {n} being removed");

            armorNode.SetFallback(weaponNode);
            weaponNode.SetFallback(legyNode);
            nodes.First(x => x.Key == "Gear").SetFallback(legacyHalfRoot);
            tree.Connect(bonusNode, (genNode, 1));
            legacyHalfRoot.AddChildNodes((crapNode, 90));

            legacyNode.IgnoreAvailability = true;

            legacyHalfRoot.Algorithm = fpl;
            bonusNode.Algorithm      = fpl;
            defaultNode.Algorithm    = fpl;
            crapNode.Algorithm       = fpl;

            nodes.ForEach(Console.WriteLine);

            for (int i = 0; i < 100; i++)
            {
                Console.WriteLine(tree.GetResult());
            }
            nodes.ForEach(Console.WriteLine);
            Console.ReadKey();
        }
 // Start is called before the first frame update
 void Start()
 {
     randomLoot    = GetComponent <RandomLoot>();
     currentHealth = maxHealth;          // verändet Wert der Healtbar
 }