public static TrapModel GetTrapModelInfo(TrapType trapType)
    {
        var staticTrap = AllTraps.FirstOrDefault(x => x.TrapName.ToLower() == trapType.ToString().ToLower());

        if (staticTrap == null)
        {
            Debug.LogError("staticTrap == null : " + trapType.ToString());
        }

        var newTrap = new TrapModel();

        CopyTrapModel(staticTrap, newTrap);

        return(newTrap);
    }
示例#2
0
 /// <summary>
 /// Gets the path of the trap type.
 /// </summary>
 /// <param name="val">The value.</param>
 /// <returns></returns>
 public static string ToDescriptionString(TrapType val)
 {
     DescriptionAttribute[] attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);
     return attributes.Length > 0 ? attributes[0].Description : string.Empty;
 }
示例#3
0
        public override void Initialise()
        {
            if (!initialised)
            {
                roomTrapType = (TrapType)(Utility.Instance.cRand.NextDouble() * (int)TrapType.MAX_TRAPS);
                Console.WriteLine("Trap type: " + roomTrapType.ToString());

                if (!defeated)
                {
                    double enemyBuffChance = Utility.Instance.cRand.NextDouble();
                    int numMonsters = (int)(Utility.Instance.cRand.NextDouble() * maxMonsters);
                    if (roomTrapType == TrapType.INCR_NUM_ENEMIES)
                    {
                        numMonsters *= 2;
                    }
                    else if (roomTrapType == TrapType.DECR_NUM_ENEMIES)
                    {
                        numMonsters = numMonsters == 0 ? 1 : numMonsters / 2;
                    }

                    if (numMonsters == 0)
                    {
                        numMonsters = 1;
                    }

                    for (int i = 0; i < numMonsters; ++i)
                    {
                        //increased values
                        Enemy t = null;
                        double typeChance = Utility.Instance.cRand.NextDouble();

                        //pursuer
                        if (typeChance >= 0 && typeChance < 0.2)
                        {
                            t = new Pursuer(new Vector2((float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenWidth - 500)), (float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenHeight - 500))), new Vector2(32), Color.Yellow);
                        }
                        else if (typeChance >= 0.2 && typeChance < 0.4)
                        {
                            t = new PursuingShooter(new Vector2((float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenWidth - 500)), (float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenHeight - 500))), new Vector2(32), Color.Yellow);
                        }
                        else if (typeChance >= 0.4 && typeChance < 0.6)
                        {
                            t = new Avoider(new Vector2((float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenWidth - 500)), (float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenHeight - 500))), new Vector2(32), Color.Yellow);
                        }
                        else if (typeChance >= 0.6 && typeChance < 0.8)
                        {
                            t = new EvadingShooter(new Vector2((float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenWidth - 500)), (float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenHeight - 500))), new Vector2(32), Color.Yellow);
                        }
                        else if (typeChance >= 0.8 && typeChance < 1)
                        {
                            t = new Shooter(new Vector2((float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenWidth - 500)), (float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenHeight - 500))), new Vector2(32), Color.Yellow);
                        }

                        if (enemyBuffChance > 0.5)
                        {
            #if DEBUG
                            enemyBuffed = true;
            #endif
                            Console.WriteLine("ENEMY GETS BUFFED");
                            switch (roomTrapType)
                            {
                                case TrapType.INCR_ATTACK_DAMAGE:
                                    t.IncreaseAttackDamage();
                                    t.IncreaseAttackDamage();
                                    t.IncreaseAttackDamage();
                                    break;
                                case TrapType.INCR_ATTACK_SPEED:
                                    t.IncreaseAttackSpeed();
                                    t.IncreaseAttackSpeed();
                                    t.IncreaseAttackSpeed();
                                    break;
                                case TrapType.INCR_BULLET_SIZE:
                                    t.IncreaseBulletSize();
                                    t.IncreaseBulletSize();
                                    t.IncreaseBulletSize();
                                    break;
                                case TrapType.INCR_MOVEMENT_SPEED:
                                    t.IncreaseMovementSpeed();
                                    t.IncreaseMovementSpeed();
                                    t.IncreaseMovementSpeed();
                                    break;
                                case TrapType.INCR_HEALTH:
                                    t.IncreaseMaxHealth();
                                    t.IncreaseMaxHealth();
                                    break;
                                default: break;
                            }
                        }

                        Console.WriteLine("Adding: " + t.GetType().ToString());
                        enemies.Add(t);
                    }

                    //player gets buffed instead
                    if (enemyBuffChance <= 0.5)
                    {
            #if DEBUG
                        enemyBuffed = false;
            #endif
                        Console.WriteLine("PLAYER GETS BUFFED");
                        Dungeon.GetPlayer.SaveStats();
                        switch (roomTrapType)
                        {
                            case TrapType.INCR_ATTACK_DAMAGE:
                                Dungeon.GetPlayer.IncreaseAttackDamage();
                                Dungeon.GetPlayer.IncreaseAttackDamage();
                                Dungeon.GetPlayer.IncreaseAttackDamage();
                                break;
                            case TrapType.INCR_ATTACK_SPEED:
                                Dungeon.GetPlayer.IncreaseAttackSpeed();
                                Dungeon.GetPlayer.IncreaseAttackSpeed();
                                Dungeon.GetPlayer.IncreaseAttackSpeed();
                                break;
                            case TrapType.INCR_BULLET_SIZE:
                                Dungeon.GetPlayer.IncreaseBulletSize();
                                Dungeon.GetPlayer.IncreaseBulletSize();
                                Dungeon.GetPlayer.IncreaseBulletSize();
                                break;
                            case TrapType.INCR_MOVEMENT_SPEED:
                                Dungeon.GetPlayer.IncreaseMovementSpeed();
                                Dungeon.GetPlayer.IncreaseMovementSpeed();
                                Dungeon.GetPlayer.IncreaseMovementSpeed();
                                break;
                            case TrapType.INCR_HEALTH:
                                Dungeon.GetPlayer.IncreaseMaxHealth();
                                Dungeon.GetPlayer.IncreaseMaxHealth();
                                break;
                            default: break;
                        }
                    }
                }
            }

            base.Initialise();
        }
示例#4
0
 private void NetworkEvents_onCharacterHitByTrap(TrapType trapType)
 {
     _manager.Socket.Emit("character_hit_by_trap", new { UserId = UserData.Instance.User.Id, trapType = trapType.ToString() });
 }