Example #1
0
        GameObject CreateHero(string name, int spriteX, int spriteY, int posX, int posY, Color col, int speed, int hp, int atk, CombatType type)
        {
            Hero   heroComponent = new Hero(name, GlobalScripts, Map[posX, posY], col, speed, hp, atk, type);
            Player player        = GlobalScripts.GetComponent <Player>();

            GameObject hero = new GameObjectBuilder()
                              .AddComponent(new Transform(new Vector2(Map.Size * posX, Map.Size * posY)))
                              .AddComponent(new SpriteRenderer(Chara))
                              .AddComponent(CreateAnimator(Chara, spriteX, spriteY))
                              .AddComponent(CreateAnimationStateMachine(Map.Size))
                              .AddComponent(heroComponent)
                              .AddComponent(new Dimentions(0, 0, Map.Size, Map.Size))
                              .AddComponent(new Hoverable(() => player.RequestInfoboxOverride(
                                                              "<" + heroComponent.Name + ">" + Environment.NewLine +
                                                              "HP: " + heroComponent.HitPoints.Remaining + " / " + heroComponent.HitPoints.Max + Environment.NewLine +
                                                              "Speed: " + heroComponent.Speed.Max + Environment.NewLine +
                                                              "Strength: " + heroComponent.Strength + Environment.NewLine +
                                                              "Type: " + heroComponent.Type,
                                                              heroComponent), () => player.InvalidateInfoboxOverride(heroComponent)))
                              .Register(this);

            Map[posX, posY].OccupiedBy = hero;
            return(hero);
        }
 //Attack type/armour type multiplier
 float AttackArmourMultiCalc(CombatType cType)
 {
     float multi = 1;
     if(armour == ArmourType.Melee && cType == CombatType.Melee)
     {
         multi -= 0.5f;
     }
     else if (armour == ArmourType.Ranged && cType == CombatType.Ranged)
     {
         multi -= 0.5f;
     }
     else if (armour == ArmourType.Magical && cType == CombatType.Spell)
     {
         multi -= 0.5f;
     }
     else if (armour == ArmourType.Mixed)
     {
         multi -= 0.25f;
     }
     return multi;
 }
Example #3
0
 public PlotCombat(object combatType)
 {
     _combatType  = (CombatType)combatType;
     targerHandle = new TargetHandle(TargetEmbattle);
 }
Example #4
0
        // Contains definitions of all animations for every character in the game.
        private void PopulateLists()
        {
            // What type of game object am I?
            switch (this.mObjectType)
            {
                case ObjectType.DRAGON:
                    {

                        //I'm a DRAGON, so define my DRAGON animations.
                        Animation MoveLeft = new Animation("Sprites/Units/Dragon/DragonFlyingLeft", 4, 1, 4, 200);
                        Animation MoveRight = new Animation("Sprites/Units/Dragon/DragonFlyingRight", 4, 1, 4, 200);
                        Animation IdleLeft = new Animation("Sprites/Units/Dragon/DragonIdleLeft", 20, 1, 20, 200);
                        Animation IdleRight = new Animation("Sprites/Units/Dragon/DragonIdleRight", 20, 1, 20, 200);
                        Animation AttackLeft = new Animation("Sprites/Units/Dragon/DragonAttackLeft", 10, 1, 10, 200);
                        Animation AttackRight = new Animation("Sprites/Units/Dragon/DragonAttackRight", 10, 1, 10, 200);
                        Animation DeathLeft = new Animation("Sprites/Units/Dragon/DragonDeathLeft", 10, 1, 10, 200);
                        Animation DeathRight = new Animation("Sprites/Units/Dragon/DragonDeathRight", 10, 1, 10, 200);

                        // Populate my list of animations. All game objects will populate animations in a consistant order.
                        // Move will always be at index 0. IDLE_LEFT will always be at index 1, etc.
                        mUnitAnimationList.Add(MoveLeft);
                        mUnitAnimationList.Add(MoveRight);
                        mUnitAnimationList.Add(IdleLeft);
                        mUnitAnimationList.Add(IdleRight);
                        mUnitAnimationList.Add(AttackLeft);
                        mUnitAnimationList.Add(AttackRight);
                        mUnitAnimationList.Add(DeathLeft);
                        mUnitAnimationList.Add(DeathRight);

                        this.mCombatType = CombatType.MELEE;
                    }
                    break;
                case ObjectType.CLERIC:
                    {

                        //I'm a CLERIC, so define my CLERIC animations.
                        Animation MoveLeft = new Animation("Sprites/Units/Cleric/ClericWalkingLeft", 4, 1, 4, 200);
                        Animation MoveRight = new Animation("Sprites/Units/Cleric/ClericWalkingRight", 4, 1, 4, 200);
                        Animation IdleLeft = new Animation("Sprites/Units/Cleric/ClericIdleLeft", 1, 1, 1, 200);
                        Animation IdleRight = new Animation("Sprites/Units/Cleric/ClericIdleRight", 1, 1, 1, 200);
                        Animation AttackLeft = new Animation("Sprites/Units/Cleric/ClericHealLeft", 3, 1, 3, 200);
                        Animation AttackRight = new Animation("Sprites/Units/Cleric/ClericHealRight", 3, 1, 3, 200);
                        Animation DeathLeft = new Animation("Sprites/Units/Cleric/ClericDeathLeft", 15, 1, 15, 200);
                        Animation DeathRight = new Animation("Sprites/Units/Cleric/ClericDeathRight", 15, 1, 15, 200);

                        // Populate my list of animations. All game objects will populate animations in a consistant order.
                        // Move will always be at index 0. IDLE_LEFT will always be at index 1, etc.
                        mUnitAnimationList.Add(MoveLeft);
                        mUnitAnimationList.Add(MoveRight);
                        mUnitAnimationList.Add(IdleLeft);
                        mUnitAnimationList.Add(IdleRight);
                        mUnitAnimationList.Add(AttackLeft);
                        mUnitAnimationList.Add(AttackRight);
                        mUnitAnimationList.Add(DeathLeft);
                        mUnitAnimationList.Add(DeathRight);

                        mCombatType = CombatType.HEALER;

                    }
                    break;

                case ObjectType.BERSERKER:
                    {

                        //I'm a BERSERKER, so define my BERSERKER animations.
                        Animation MoveLeft = new Animation("Sprites/Units/Berzerker/BerzerkerWalkingLeft", 7, 1, 7, 200);
                        Animation MoveRight = new Animation("Sprites/Units/Berzerker/BerzerkerWalkingRight", 7, 1, 7, 200);
                        Animation IdleLeft = new Animation("Sprites/Units/Berzerker/BerzerkerIdleLeft", 6, 1, 6, 200);
                        Animation IdleRight = new Animation("Sprites/Units/Berzerker/BerzerkerIdleRight", 6, 1, 6, 200);
                        Animation AttackLeft = new Animation("Sprites/Units/Berzerker/BerzerkerAttackLeft", 5, 1, 5, 200);
                        Animation AttackRight = new Animation("Sprites/Units/Berzerker/BerzerkerAttackRight", 5, 1, 5, 200);
                        Animation DeathLeft = new Animation("Sprites/Units/Berzerker/BerzerkerDyingLeft", 6, 1, 6, 200);
                        Animation DeathRight = new Animation("Sprites/Units/Berzerker/BerzerkerDyingRight", 6, 1, 6, 200);

                        // Populate my list of animations. All game objects will populate animations in a consistant order.
                        // Move will always be at index 0. IDLE_LEFT will always be at index 1, etc.
                        mUnitAnimationList.Add(MoveLeft);
                        mUnitAnimationList.Add(MoveRight);
                        mUnitAnimationList.Add(IdleLeft);
                        mUnitAnimationList.Add(IdleRight);
                        mUnitAnimationList.Add(AttackLeft);
                        mUnitAnimationList.Add(AttackRight);
                        mUnitAnimationList.Add(DeathLeft);
                        mUnitAnimationList.Add(DeathRight);

                        mCombatType = CombatType.MELEE;
                    }
                    break;
                // THIS IS AXE THROWER
                case ObjectType.AXE_THROWER:
                    {

                        //I'm a AXE_THROWER, so define my AXE_THROWER animations.
                        Animation MoveLeft = new Animation("Sprites/Units/AxeThrower/AxeThrowerWalkingLeft", 7, 1, 7, 200);
                        Animation MoveRight = new Animation("Sprites/Units/AxeThrower/AxeThrowerWalkingRight", 7, 1, 7, 200);
                        Animation IdleLeft = new Animation("Sprites/Units/AxeThrower/AxeThrowerIdleLeft", 3, 1, 3, 200);
                        Animation IdleRight = new Animation("Sprites/Units/AxeThrower/AxeThrowerIdleRight", 3, 1, 3, 200);
                        Animation AttackLeft = new Animation("Sprites/Units/AxeThrower/AxeThrowerAttackLeft", 6, 1, 6, 200);
                        Animation AttackRight = new Animation("Sprites/Units/AxeThrower/AxeThrowerAttackRight", 6, 1, 6, 200);
                        Animation DeathLeft = new Animation("Sprites/Units/AxeThrower/AxeThrowerDyingLeft", 3, 1, 3, 200);
                        Animation DeathRight = new Animation("Sprites/Units/AxeThrower/AxeThrowerDyingRight", 3, 1, 3, 200);

                        // Populate my list of animations. All game objects will populate animations in a consistant order.
                        // Move will always be at index 0. IDLE_LEFT will always be at index 1, etc.
                        mUnitAnimationList.Add(MoveLeft);
                        mUnitAnimationList.Add(MoveRight);
                        mUnitAnimationList.Add(IdleLeft);
                        mUnitAnimationList.Add(IdleRight);
                        mUnitAnimationList.Add(AttackLeft);
                        mUnitAnimationList.Add(AttackRight);
                        mUnitAnimationList.Add(DeathLeft);
                        mUnitAnimationList.Add(DeathRight);

                        mCombatType = CombatType.RANGED;

                    }
                    break;
                case ObjectType.FIRE_MAGE:
                    {

                        //I'm a FIRE_MAGE, so define my FIRE_MAGE animations.
                        Animation MoveLeft = new Animation("Sprites/Units/FireMage/FireWalkingLeft", 14, 1, 14, 200);
                        Animation MoveRight = new Animation("Sprites/Units/FireMage/FireWalkingRight", 14, 1, 14, 200);
                        Animation IdleLeft = new Animation("Sprites/Units/FireMage/FireIdleLeft", 15, 1, 15, 200);
                        Animation IdleRight = new Animation("Sprites/Units/FireMage/FireIdleRight", 15, 1, 15, 200);
                        Animation AttackLeft = new Animation("Sprites/Units/FireMage/FireAttackLeft", 6, 1, 6, 200);
                        Animation AttackRight = new Animation("Sprites/Units/FireMage/FireAttackRight", 6, 1, 6, 200);
                        Animation DeathLeft = new Animation("Sprites/Units/FireMage/FireDyingLeft", 1, 1, 1, 200);
                        Animation DeathRight = new Animation("Sprites/Units/FireMage/FireDyingRight", 1, 1, 1, 200);

                        // Populate my list of animations. All game objects will populate animations in a consistant order.
                        // Move will always be at index 0. IDLE_LEFT will always be at index 1, etc.
                        mUnitAnimationList.Add(MoveLeft);
                        mUnitAnimationList.Add(MoveRight);
                        mUnitAnimationList.Add(IdleLeft);
                        mUnitAnimationList.Add(IdleRight);
                        mUnitAnimationList.Add(AttackLeft);
                        mUnitAnimationList.Add(AttackRight);
                        mUnitAnimationList.Add(DeathLeft);
                        mUnitAnimationList.Add(DeathRight);

                        mCombatType = CombatType.RANGED;

                    }
                    break;
                case ObjectType.NECROMANCER:
                    {

                        //I'm a NECROMANCER, so define my NECROMANCER animations.
                        Animation MoveLeft = new Animation("Sprites/Units/Necro/NecroWalkingLeft", 6, 1, 6, 200);
                        Animation MoveRight = new Animation("Sprites/Units/Necro/NecroWalkingRight", 6, 1, 6, 200);
                        Animation IdleLeft = new Animation("Sprites/Units/Necro/NecroIdleLeft", 1, 1, 1, 200);
                        Animation IdleRight = new Animation("Sprites/Units/Necro/NecroIdleRight", 1, 1, 1, 200);
                        Animation AttackLeft = new Animation("Sprites/Units/Necro/NecroAttackingLeft", 4, 1, 4, 200);
                        Animation AttackRight = new Animation("Sprites/Units/Necro/NecroAttackingRight", 4, 1, 4, 200);
                        Animation DeathLeft = new Animation("Sprites/Units/Necro/NecroDyingLeft", 8, 1, 8, 100);
                        Animation DeathRight = new Animation("Sprites/Units/Necro/NecroDyingRight", 8, 1, 8, 100);

                        // Populate my list of animations. All game objects will populate animations in a consistant order.
                        // Move will always be at index 0. IDLE_LEFT will always be at index 1, etc.
                        mUnitAnimationList.Add(MoveLeft);
                        mUnitAnimationList.Add(MoveRight);
                        mUnitAnimationList.Add(IdleLeft);
                        mUnitAnimationList.Add(IdleRight);
                        mUnitAnimationList.Add(AttackLeft);
                        mUnitAnimationList.Add(AttackRight);
                        mUnitAnimationList.Add(DeathLeft);
                        mUnitAnimationList.Add(DeathRight);

                        mCombatType = CombatType.RANGED;
                    }
                    break;

                case ObjectType.WOLF:
                    {

                        //I'm a WOLF, so define my WOLF animations.
                        Animation MoveLeft = new Animation("Sprites/Units/Wolf/WolfWalkingLeft", 8, 1, 8, 200);
                        Animation MoveRight = new Animation("Sprites/Units/Wolf/WolfWalkingRight", 8, 1, 8, 200);
                        Animation IdleLeft = new Animation("Sprites/Units/Wolf/WolfIdleLeft", 14, 1, 14, 200);
                        Animation IdleRight = new Animation("Sprites/Units/Wolf/WolfIdleRight", 14, 1, 14, 200);
                        Animation AttackLeft = new Animation("Sprites/Units/Wolf/WolfAttackLeft", 4, 1, 4, 200);
                        Animation AttackRight = new Animation("Sprites/Units/Wolf/WolfAttackRight", 4, 1, 4, 200);
                        Animation DeathLeft = new Animation("Sprites/Units/Wolf/WolfDyingLeft", 4, 1, 4, 200);
                        Animation DeathRight = new Animation("Sprites/Units/Wolf/WolfDyingRight", 4, 1, 4, 200);

                        // Populate my list of animations. All game objects will populate animations in a consistant order.
                        // Move will always be at index 0. IDLE_LEFT will always be at index 1, etc.
                        mUnitAnimationList.Add(MoveLeft);
                        mUnitAnimationList.Add(MoveRight);
                        mUnitAnimationList.Add(IdleLeft);
                        mUnitAnimationList.Add(IdleRight);
                        mUnitAnimationList.Add(AttackLeft);
                        mUnitAnimationList.Add(AttackRight);
                        mUnitAnimationList.Add(DeathLeft);
                        mUnitAnimationList.Add(DeathRight);

                        mCombatType = CombatType.MELEE;
                    }
                    break;
                case ObjectType.ARCANE_MAGE:
                    {

                        //I'm a ARCANE_MAGE, so define my ARCANE_MAGE animations.
                        Animation MoveLeft = new Animation("Sprites/Units/ArcaneMage/ArcaneWalkingLeft", 6, 1, 6, 200);
                        Animation MoveRight = new Animation("Sprites/Units/ArcaneMage/ArcaneWalkingRight", 6, 1, 6, 200);
                        Animation IdleLeft = new Animation("Sprites/Units/ArcaneMage/ArcaneIdleLeft", 1, 1, 1, 200);
                        Animation IdleRight = new Animation("Sprites/Units/ArcaneMage/ArcaneIdleRight", 1, 1, 1, 200);
                        Animation AttackLeft = new Animation("Sprites/Units/ArcaneMage/ArcaneAttackLeft", 4, 1, 4, 200);
                        Animation AttackRight = new Animation("Sprites/Units/ArcaneMage/ArcaneAttackRight", 4, 1, 4, 200);
                        Animation DeathLeft = new Animation("Sprites/Units/ArcaneMage/ArcaneMageDeathLeft", 9, 1, 9, 200);
                        Animation DeathRight = new Animation("Sprites/Units/ArcaneMage/ArcaneMageDeathRight", 9, 1, 9, 200);

                        // Populate my list of animations. All game objects will populate animations in a consistant order.
                        // Move will always be at index 0. IDLE_LEFT will always be at index 1, etc.
                        mUnitAnimationList.Add(MoveLeft);
                        mUnitAnimationList.Add(MoveRight);
                        mUnitAnimationList.Add(IdleLeft);
                        mUnitAnimationList.Add(IdleRight);
                        mUnitAnimationList.Add(AttackLeft);
                        mUnitAnimationList.Add(AttackRight);
                        mUnitAnimationList.Add(DeathLeft);
                        mUnitAnimationList.Add(DeathRight);

                        mCombatType = CombatType.RANGED;
                    }
                    break;

                //TODO: THIS IS IMP
                case ObjectType.IMP:
                    {

                        //I'm a IMP, so define my IMP animations.
                        Animation MoveLeft = new Animation("Sprites/Units/Imp/ImpWalkingLeft", 4, 1, 4, 200);
                        Animation MoveRight = new Animation("Sprites/Units/Imp/ImpWalkingRight", 4, 1, 4, 200);
                        Animation AttackLeft = new Animation("Sprites/Units/Imp/ImpAttackingLeft", 4, 1, 4, 200);
                        Animation AttackRight = new Animation("Sprites/Units/Imp/ImpAttackingRight", 4, 1, 4, 200);
                        Animation DeathLeft = new Animation("Sprites/Units/Imp/ImpDyingLeft", 14, 1, 14, 150);
                        Animation DeathRight = new Animation("Sprites/Units/Imp/ImpDyingRight", 14, 1, 14, 150);
                        Animation IdleLeft = new Animation("Sprites/Units/Imp/ImpIdleLeft", 1, 1, 1, 200);
                        Animation IdleRight = new Animation("Sprites/Units/Imp/ImpIdleRight", 1, 1, 1, 200);

                        // Populate my list of animations. All game objects will populate animations in a consistant order.
                        // Move will always be at index 0. IDLE_LEFT will always be at index 1, etc.
                        mUnitAnimationList.Add(MoveLeft);
                        mUnitAnimationList.Add(MoveRight);
                        mUnitAnimationList.Add(IdleLeft);
                        mUnitAnimationList.Add(IdleRight);
                        mUnitAnimationList.Add(AttackLeft);
                        mUnitAnimationList.Add(AttackRight);
                        mUnitAnimationList.Add(DeathLeft);
                        mUnitAnimationList.Add(DeathRight);

                        mCombatType = CombatType.MELEE;
                    }
                    break;
                case ObjectType.GOG:
                    {

                        //I'm a GOG, so define my GOG animations.
                        Animation MoveLeft = new Animation("Sprites/Units/Gog/GogWalkingLeft", 5, 1, 5, 200);
                        Animation MoveRight = new Animation("Sprites/Units/Gog/GogWalkingRight", 5, 1, 5, 200);
                        Animation AttackLeft = new Animation("Sprites/Units/Gog/GogAttackingLeft", 3, 1, 3, 200);
                        Animation AttackRight = new Animation("Sprites/Units/Gog/GogAttackingRight", 3, 1, 3, 200);
                        Animation DeathLeft = new Animation("Sprites/Units/Gog/GogDyingLeft", 15, 1, 15, 200);
                        Animation DeathRight = new Animation("Sprites/Units/Gog/GogDyingRight", 15, 1, 15, 200);
                        Animation IdleLeft = new Animation("Sprites/Units/Gog/GogWalkingLeft", 0, 1, 1, 200);
                        Animation IdleRight = new Animation("Sprites/Units/Gog/GogWalkingRight", 0, 1, 1, 200);

                        // Populate my list of animations. All game objects will populate animations in a consistant order.
                        // Move will always be at index 0. IDLE_LEFT will always be at index 1, etc.
                        mUnitAnimationList.Add(MoveLeft);
                        mUnitAnimationList.Add(MoveRight);
                        mUnitAnimationList.Add(IdleLeft);
                        mUnitAnimationList.Add(IdleRight);
                        mUnitAnimationList.Add(AttackLeft);
                        mUnitAnimationList.Add(AttackRight);
                        mUnitAnimationList.Add(DeathLeft);
                        mUnitAnimationList.Add(DeathRight);

                        mCombatType = CombatType.RANGED;

                    }
                    break;

                // THIS IS BANSHEE
                case ObjectType.BANSHEE:
                    {

                        //I'm a BANSHEE, so define my BANSHEE animations.
                        Animation MoveLeft = new Animation("Sprites/Units/Banshee/BansheeWalkingLeft", 6, 1, 6, 200);
                        Animation MoveRight = new Animation("Sprites/Units/Banshee/BansheeWalkingRight", 6, 1, 6, 200);
                        Animation AttackLeft = new Animation("Sprites/Units/Banshee/BansheeAttackingLeft", 2, 1, 2, 100);
                        Animation AttackRight = new Animation("Sprites/Units/Banshee/BansheeAttackingLeft", 2, 1, 2, 100);
                        Animation DeathLeft = new Animation("Sprites/Units/Banshee/BansheeDeathLeft", 5, 1, 5, 200);
                        Animation DeathRight = new Animation("Sprites/Units/Banshee/BansheeDeathRight", 5, 1, 5, 200);
                        Animation IdleLeft = new Animation("Sprites/Units/Banshee/BansheeAttackingLeft", 0, 1, 1, 200);
                        Animation IdleRight = new Animation("Sprites/Units/Banshee/BansheeAttackingRight", 0, 1, 1, 200);

                        // Populate my list of animations. All game objects will populate animations in a consistant order.
                        // Move will always be at index 0. IDLE_LEFT will always be at index 1, etc.
                        mUnitAnimationList.Add(MoveLeft);
                        mUnitAnimationList.Add(MoveRight);
                        mUnitAnimationList.Add(IdleLeft);
                        mUnitAnimationList.Add(IdleRight);
                        mUnitAnimationList.Add(AttackLeft);
                        mUnitAnimationList.Add(AttackRight);
                        mUnitAnimationList.Add(DeathLeft);
                        mUnitAnimationList.Add(DeathRight);

                        mCombatType = CombatType.RANGED;
                    }
                    break;
                // TODO: THIS IS REAPER
                case ObjectType.REAPER:
                    {

                        //I'm a REAPER, so define my REAPER animations.
                        Animation MoveLeft = new Animation("Sprites/Units/Reaper/ReaperWalkingLeft", 9, 1, 9, 200);
                        Animation MoveRight = new Animation("Sprites/Units/Reaper/ReaperWalkingRight", 9, 1, 9, 200);
                        Animation AttackLeft = new Animation("Sprites/Units/Reaper/ReaperAttackingLeft", 6, 1, 6, 200);
                        Animation AttackRight = new Animation("Sprites/Units/Reaper/ReaperAttackingRight", 6, 1, 6, 200);
                        Animation DeathLeft = new Animation("Sprites/Units/Reaper/ReaperDyingLeft", 16, 2, 16, 200);
                        Animation DeathRight = new Animation("Sprites/Units/Reaper/ReaperDyingRight", 16, 2, 16, 200);
                        Animation IdleLeft = new Animation("Sprites/Units/Reaper/ReaperWalkingLeft", 9, 1, 9, 200);
                        Animation IdleRight = new Animation("Sprites/Units/Reaper/ReaperWalkingRight", 9, 1, 9, 200);

                        // Populate my list of animations. All game objects will populate animations in a consistant order.
                        // Move will always be at index 0. IDLE_LEFT will always be at index 1, etc.
                        mUnitAnimationList.Add(MoveLeft);
                        mUnitAnimationList.Add(MoveRight);
                        mUnitAnimationList.Add(IdleLeft);
                        mUnitAnimationList.Add(IdleRight);
                        mUnitAnimationList.Add(AttackLeft);
                        mUnitAnimationList.Add(AttackRight);
                        mUnitAnimationList.Add(DeathLeft);
                        mUnitAnimationList.Add(DeathRight);
                        mCombatType = CombatType.MELEE;
                    }
                    break;
                case ObjectType.DOOM_HOUND:
                    {

                        //I'm a DOOM_HOUND, so define my DOOM_HOUND animations.
                        Animation MoveLeft = new Animation("Sprites/Units/DoomHound/DoomHoundWalkLeft", 10, 1, 10, 200);
                        Animation MoveRight = new Animation("Sprites/Units/DoomHound/DoomHoundWalkRight", 10, 1, 10, 200);
                        Animation AttackLeft = new Animation("Sprites/Units/DoomHound/DoomHoundAttackLeft", 8, 1, 8, 200);
                        Animation AttackRight = new Animation("Sprites/Units/DoomHound/DoomHoundAttackRight", 8, 1, 8, 200);
                        Animation DeathLeft = new Animation("Sprites/Units/DoomHound/DoomHoundDeathLeft", 6, 1, 6, 150);
                        Animation DeathRight = new Animation("Sprites/Units/DoomHound/DoomHoundDeathRight", 6, 1, 6, 150);
                        Animation IdleLeft = new Animation("Sprites/Units/DoomHound/DoomHoundWalkLeft", 10, 1, 10, 200);
                        Animation IdleRight = new Animation("Sprites/Units/DoomHound/DoomHoundWalkRight", 10, 1, 10, 200);

                        // Populate my list of animations. All game objects will populate animations in a consistant order.
                        // Move will always be at index 0. IDLE_LEFT will always be at index 1, etc.
                        mUnitAnimationList.Add(MoveLeft);
                        mUnitAnimationList.Add(MoveRight);
                        mUnitAnimationList.Add(IdleLeft);
                        mUnitAnimationList.Add(IdleRight);
                        mUnitAnimationList.Add(AttackLeft);
                        mUnitAnimationList.Add(AttackRight);
                        mUnitAnimationList.Add(DeathLeft);
                        mUnitAnimationList.Add(DeathRight);

                        mCombatType = CombatType.MELEE;
                    }
                    break;
                case ObjectType.HERO:
                    {

                        //I'm a HERO, so define my HERO animations.
                        Animation MoveLeft = new Animation("Sprites/Hero/HeroWalkingLeft", 4, 1, 4, 200);
                        Animation MoveRight = new Animation("Sprites/Hero/HeroWalkingRight", 4, 1, 4, 200);
                        Animation IdleLeft = new Animation("Sprites/Hero/HeroIdleLeft", 12, 1, 12, 200);
                        Animation IdleRight = new Animation("Sprites/Hero/HeroIdleRight", 12, 1, 12, 200);
                        Animation AttackLeft = new Animation("Sprites/Hero/HeroAttackingLeft", 4, 1, 4, 200);
                        Animation AttackRight = new Animation("Sprites/Hero/HeroAttackingRight", 4, 1, 4, 200);
                        Animation DeathLeft = new Animation("Sprites/Hero/HeroDyingLeft", 10, 1, 10, 150);
                        Animation DeathRight = new Animation("Sprites/Hero/HeroDyingRight", 10, 1, 10, 150);
                        Animation CastBattleCryLeft = new Animation("Sprites/Hero/HeroCastBattleCryLeft", 11, 0, 11, 200);
                        Animation CastBattleCryRight = new Animation("Sprites/Hero/HeroCastBattleCryRight", 11, 0, 11, 200);
                        Animation CastIntimidateLeft = new Animation("Sprites/Hero/HeroCastIntimidateLeft", 11, 0, 11, 200);
                        Animation CastIntimidateRight = new Animation("Sprites/Hero/HeroCastIntimidateRight", 11, 0, 11, 200);

                        // Populate my list of animations. All game objects will populate animations in a consistant order.
                        // Move will always be at index 0. IDLE_LEFT will always be at index 1, etc.
                        mUnitAnimationList.Add(MoveLeft);
                        mUnitAnimationList.Add(MoveRight);
                        mUnitAnimationList.Add(IdleLeft);
                        mUnitAnimationList.Add(IdleRight);
                        mUnitAnimationList.Add(AttackLeft);
                        mUnitAnimationList.Add(AttackRight);
                        mUnitAnimationList.Add(DeathLeft);
                        mUnitAnimationList.Add(DeathRight);
                        mUnitAnimationList.Add(CastBattleCryLeft);
                        mUnitAnimationList.Add(CastBattleCryRight);
                        mUnitAnimationList.Add(CastIntimidateLeft);
                        mUnitAnimationList.Add(CastIntimidateRight);

                        mCombatType = CombatType.MELEE;
                    }
                    break;
                case ObjectType.ORC_CASTLE:
                    {
                        Animation Castle = new Animation("Sprites/Structures/OrcCastle2", 1, 1, 1, 100000);
                        // Animation Castle = new Animation("Sprites/Castle/NecromancerStructure", 10, 1, 10, 500);
                        mUnitAnimationList.Add(Castle);

                    }
                    break;
                case ObjectType.DRAGON_CAVE:
                    {
                        Animation Structure = new Animation("Sprites/Structures/DragonCave", 9, 1, 9, 500);

                        mUnitAnimationList.Add(Structure);

                    }
                    break;
                case ObjectType.ABBEY:
                    {
                        Animation Structure = new Animation("Sprites/Structures/Abbey", 20, 1, 20, 200);

                        mUnitAnimationList.Add(Structure);

                    }
                    break;
                case ObjectType.BONEPIT:
                    {
                        Animation Structure = new Animation("Sprites/Structures/BonePit", 10, 1, 10, 200);

                        mUnitAnimationList.Add(Structure);

                    }
                    break;
                case ObjectType.FIRE_TEMPLE:
                    {
                        Animation Structure = new Animation("Sprites/Structures/FireTemple", 9, 1, 9, 200);

                        mUnitAnimationList.Add(Structure);

                    }
                    break;
                case ObjectType.WOLFPEN:
                    {
                        Animation Structure = new Animation("Sprites/Structures/WolfPen", 1, 1, 1, 100000);

                        mUnitAnimationList.Add(Structure);

                    }
                    break;
                case ObjectType.LIBRARY:
                    {
                        Animation Structure = new Animation("Sprites/Structures/Library", 21, 1, 21, 100000);

                        mUnitAnimationList.Add(Structure);

                    }
                    break;
                case ObjectType.ARMORY:
                    {
                        Animation Structure = new Animation("Sprites/Structures/Armory", 1, 1, 1, 100000);

                        mUnitAnimationList.Add(Structure);

                    }
                    break;
                case ObjectType.BARRACKS:
                    {
                        Animation Structure = new Animation("Sprites/Structures/Barracks", 1, 1, 1, 100000);

                        mUnitAnimationList.Add(Structure);

                    }
                    break;
                case ObjectType.FIRE_MAGE_PROJECTILE:
                    {

                        //Give me my axe I can throw at my foes!
                        Animation CastLeft = new Animation("Sprites/Units/FireMage/FireballLeft", 5, 1, 5, 200);
                        Animation CastRight = new Animation("Sprites/Units/FireMage/FireballRight", 5, 1, 5, 200);

                        mProjectileAnimationList.Add(CastLeft);
                        mProjectileAnimationList.Add(CastRight);
                    }
                    break;
                case ObjectType.GOG_PROJECTILE:
                    {

                        //Give me my axe I can throw at my foes!
                        Animation CastLeft = new Animation("Sprites/Units/Gog/FireballLeft", 5, 1, 5, 100);
                        Animation CastRight = new Animation("Sprites/Units/Gog/FireballRight", 5, 1, 5, 100);

                        mProjectileAnimationList.Add(CastLeft);
                        mProjectileAnimationList.Add(CastRight);
                    }
                    break;
                case ObjectType.NECROMANCER_PROJECTILE:
                    {

                        //Give me my axe I can throw at my foes!
                        Animation CastLeft = new Animation("Sprites/Units/Necro/SkullChompLeft", 8, 1, 8, 200);
                        Animation CastRight = new Animation("Sprites/Units/Necro/SkullChompRight", 8, 1, 8, 200);

                        mProjectileAnimationList.Add(CastLeft);
                        mProjectileAnimationList.Add(CastRight);
                    }
                    break;
                //TODO: THIS IS A BANSHEE PROJECTILE
                case ObjectType.BANSHEE_PROJECTILE:
                    {
                        //Give me my axe I can throw at my foes!
                        Animation CastLeft = new Animation("Sprites/Units/Banshee/SkullLeft", 4, 1, 4, 150);
                        Animation CastRight = new Animation("Sprites/Units/Banshee/SkullRight", 4, 1, 4, 150);
                        mProjectileAnimationList.Add(CastLeft);
                        mProjectileAnimationList.Add(CastRight);
                    }
                    break;
                case ObjectType.ARCANE_MAGE_PROJECTILE:
                    {

                        //Give me my axe I can throw at my foes!
                        Animation CastLeft = new Animation("Sprites/Units/ArcaneMage/ArcaneOrbLeft", 5, 1, 5, 200);
                        Animation CastRight = new Animation("Sprites/Units/ArcaneMage/ArcaneOrbRight", 5, 1, 5, 200);
                        mProjectileAnimationList.Add(CastLeft);
                        mProjectileAnimationList.Add(CastRight);
                    }
                    break;
                // THIS IS AN AXE THROWER PROJECTILE
                case ObjectType.AXE_THROWER_PROJECTILE:
                    {

                        //Give me my axe I can throw at my foes!
                        Animation CastLeft = new Animation("Sprites/Units/AxeThrower/AxeThrowerSpellLeft", 12, 1, 12, 100);
                        Animation CastRight = new Animation("Sprites/Units/AxeThrower/AxeThrowerSpellRight", 12, 1, 12, 100);

                        mProjectileAnimationList.Add(CastLeft);
                        mProjectileAnimationList.Add(CastRight);
                    }
                    break;
                case ObjectType.GOLD:
                    //TODO:
                    Animation GoldAnimation = new Animation("Sprites/ItemDrops/COIN", 59, 1, 59, 50);

                    mItemDropAnimation = GoldAnimation;

                    break;
                case ObjectType.HEALTH:
                    Animation HealthDropAnimation = new Animation("Sprites/ItemDrops/HealthPickupAnimation", 15, 1, 15, 200);

                    mItemDropAnimation = HealthDropAnimation;

                    break;
                default:
                    throw new ArgumentOutOfRangeException();
                    break;
            }
        }
Example #5
0
 public PlotCombat(object combatType)
 {
     _combatType = (CombatType)combatType;
     targerHandle = new TargetHandle(TargetEmbattle);
 }
Example #6
0
        private float DoCalculateDamage(Creature attacker, Creature defender, WorldObject damageSource)
        {
            var playerAttacker = attacker as Player;
            var playerDefender = defender as Player;

            Attacker = attacker;
            Defender = defender;

            CombatType = damageSource.ProjectileSource == null ? CombatType.Melee : CombatType.Missile;

            DamageSource = damageSource;

            Weapon = damageSource.ProjectileSource == null?attacker.GetEquippedMeleeWeapon() : damageSource.ProjectileLauncher;

            AttackType   = attacker.AttackType;
            AttackHeight = attacker.AttackHeight ?? AttackHeight.Medium;

            // check lifestone protection
            if (playerDefender != null && playerDefender.UnderLifestoneProtection)
            {
                LifestoneProtection = true;
                playerDefender.HandleLifestoneProtection();
                return(0.0f);
            }

            if (defender.Invincible)
            {
                return(0.0f);
            }

            // overpower
            if (attacker.Overpower != null)
            {
                Overpower = Creature.GetOverpower(attacker, defender);
            }

            // evasion chance
            if (!Overpower)
            {
                EvasionChance = GetEvadeChance(attacker, defender);
                if (EvasionChance > ThreadSafeRandom.Next(0.0f, 1.0f))
                {
                    Evaded = true;
                    return(0.0f);
                }
            }

            // get base damage
            if (playerAttacker != null)
            {
                GetBaseDamage(playerAttacker);
            }
            else
            {
                GetBaseDamage(attacker, AttackMotion ?? MotionCommand.Invalid);
            }

            if (DamageType == DamageType.Undef && !AllowDamageTypeUndef.Contains(damageSource.WeenieClassId))
            {
                log.Error($"DamageEvent.DoCalculateDamage({attacker?.Name} ({attacker?.Guid}), {defender?.Name} ({defender?.Guid}), {damageSource?.Name} ({damageSource?.Guid})) - DamageType == DamageType.Undef");
                GeneralFailure = true;
            }

            if (GeneralFailure)
            {
                return(0.0f);
            }

            // get damage modifiers
            PowerMod     = attacker.GetPowerMod(Weapon);
            AttributeMod = attacker.GetAttributeMod(Weapon);
            SlayerMod    = WorldObject.GetWeaponCreatureSlayerModifier(attacker, defender);

            // ratings
            DamageRatingBaseMod = Creature.GetPositiveRatingMod(attacker.GetDamageRating());
            RecklessnessMod     = Creature.GetRecklessnessMod(attacker, defender);
            SneakAttackMod      = attacker.GetSneakAttackMod(defender);
            HeritageMod         = attacker.GetHeritageBonus(Weapon) ? 1.05f : 1.0f;

            DamageRatingMod = Creature.AdditiveCombine(DamageRatingBaseMod, RecklessnessMod, SneakAttackMod, HeritageMod);

            // damage before mitigation
            DamageBeforeMitigation = BaseDamage * AttributeMod * PowerMod * SlayerMod * DamageRatingMod;

            // critical hit?
            var attackSkill = attacker.GetCreatureSkill(attacker.GetCurrentWeaponSkill());

            CriticalChance = WorldObject.GetWeaponCriticalChance(attacker, attackSkill, defender);

            // https://asheron.fandom.com/wiki/Announcements_-_2002/08_-_Atonement
            // It should be noted that any time a character is logging off, PK or not, all physical attacks against them become automatically critical.
            // (Note that spells do not share this behavior.) We hope this will stress the need to log off in a safe place.

            if (playerDefender != null && (playerDefender.IsLoggingOut || playerDefender.PKLogout))
            {
                CriticalChance = 1.0f;
            }

            if (CriticalChance > ThreadSafeRandom.Next(0.0f, 1.0f))
            {
                if (playerDefender != null && playerDefender.AugmentationCriticalDefense > 0)
                {
                    var criticalDefenseMod    = playerAttacker != null ? 0.05f : 0.25f;
                    var criticalDefenseChance = playerDefender.AugmentationCriticalDefense * criticalDefenseMod;

                    if (criticalDefenseChance > ThreadSafeRandom.Next(0.0f, 1.0f))
                    {
                        CriticalDefended = true;
                    }
                }

                if (!CriticalDefended)
                {
                    IsCritical = true;

                    CriticalDamageMod = 1.0f + WorldObject.GetWeaponCritDamageMod(attacker, attackSkill, defender);

                    // recklessness excluded from crits
                    RecklessnessMod        = 1.0f;
                    DamageRatingMod        = Creature.AdditiveCombine(DamageRatingBaseMod, SneakAttackMod, HeritageMod);
                    DamageBeforeMitigation = BaseDamageMod.MaxDamage * AttributeMod * PowerMod * SlayerMod * DamageRatingMod * CriticalDamageMod;
                }
            }

            // armor rending and cleaving
            var armorRendingMod = 1.0f;

            if (Weapon != null && Weapon.HasImbuedEffect(ImbuedEffectType.ArmorRending))
            {
                armorRendingMod = WorldObject.GetArmorRendingMod(attackSkill);
            }

            var armorCleavingMod = attacker.GetArmorCleavingMod(Weapon);

            var ignoreArmorMod = Math.Min(armorRendingMod, armorCleavingMod);

            // get body part / armor pieces / armor modifier
            if (playerDefender != null)
            {
                // select random body part @ current attack height
                GetBodyPart(AttackHeight);

                // get player armor pieces
                Armor = attacker.GetArmorLayers(playerDefender, BodyPart);

                // get armor modifiers
                ArmorMod = attacker.GetArmorMod(playerDefender, DamageType, Armor, Weapon, ignoreArmorMod);
            }
            else
            {
                // determine height quadrant
                Quadrant = GetQuadrant(Defender, Attacker, AttackHeight, DamageSource);

                // select random body part @ current attack height
                GetBodyPart(Defender, Quadrant);
                if (Evaded)
                {
                    return(0.0f);
                }

                Armor = CreaturePart.GetArmorLayers(PropertiesBodyPart.Key);

                // get target armor
                ArmorMod = CreaturePart.GetArmorMod(DamageType, Armor, Attacker, Weapon, ignoreArmorMod);
            }

            if (Weapon != null && Weapon.HasImbuedEffect(ImbuedEffectType.IgnoreAllArmor))
            {
                ArmorMod = 1.0f;
            }

            // get resistance modifiers
            WeaponResistanceMod = WorldObject.GetWeaponResistanceModifier(attacker, attackSkill, DamageType);

            if (playerDefender != null)
            {
                ResistanceMod = playerDefender.GetResistanceMod(DamageType, Attacker, Weapon, WeaponResistanceMod);
            }
            else
            {
                var resistanceType = Creature.GetResistanceType(DamageType);
                ResistanceMod = (float)Math.Max(0.0f, defender.GetResistanceMod(resistanceType, Attacker, Weapon, WeaponResistanceMod));
            }

            // damage resistance rating
            DamageResistanceRatingMod = defender.GetDamageResistRatingMod(CombatType);

            // get shield modifier
            ShieldMod = defender.GetShieldMod(attacker, DamageType, Weapon);

            // calculate final output damage
            Damage          = DamageBeforeMitigation * ArmorMod * ShieldMod * ResistanceMod * DamageResistanceRatingMod;
            DamageMitigated = DamageBeforeMitigation - Damage;

            return(Damage);
        }
Example #7
0
 public ItemTable GetItemTable(CombatType type)
 {
     return(csvReader.GetItemTable(type));
 }
Example #8
0
    // Update is called once per frame
    void Update()
    {
        Vector3 playerPos = target.transform.position; //プレイヤーの位置

        direction = playerPos - transform.position;    //方向
        direction = direction.normalized;              //単位化(距離要素を取り除く)

        anim.SetFloat("x", rigid.velocity.x);
        anim.SetFloat("z", rigid.velocity.z);
        float distanse = Vector3.Distance(playerPos, transform.position);         //相手との距離


        if (distanse <= 0.8f)
        {
            if (dir == direction)
            {
                isMove = false;
                DashEnd();
                rigid.velocity = Vector3.zero;
                //StopCoroutine (MidAction());
                StopCoroutine(FarAction());
                //isChase = false;
            }
        }
        if (distanse <= 1)
        {
            isChase = true;
            cState  = CombatType.near;
            StopCoroutine(MidAction());
        }
        else if (distanse <= 5)
        {
            cState = CombatType.mid;
        }
        else
        {
            cState = CombatType.far;
        }

        //combat
        switch (cState)
        {
        case CombatType.near:

            StartCoroutine(NearAction());
            break;

        case CombatType.mid:
            StartCoroutine(MidAction());
            break;

        case CombatType.far:
            StartCoroutine(FarAction());

            FollwTarget(direction);
            break;
        }


        //FollwTarget ();

        if (isMove)
        {
            FollwTarget(dir);
        }

        LookAtTarget();



        if (anim.GetCurrentAnimatorStateInfo(0).IsTag("Attack"))
        {
            canMove              = false;
            canCombo             = true;
            anim.applyRootMotion = true;
        }
        else
        {
            canCombo             = false;
            anim.applyRootMotion = false;
        }

        if (anim.GetCurrentAnimatorStateInfo(0).IsTag("Move"))
        {
            canCombo = false;
            canMove  = true;
            anim.ResetTrigger("Combo");
        }

        if (anim.GetCurrentAnimatorStateInfo(0).IsName("DashAttack"))
        {
            rigid.AddForce(transform.forward * 40);
        }


        //移動管理
        if (anim.GetCurrentAnimatorStateInfo(0).IsTag("Move") || anim.GetCurrentAnimatorStateInfo(0).IsName("Dash"))
        {
            canMove = true;

            isRotate = true;
        }
        else
        {
            canMove  = false;
            isRotate = false;
        }

        if (!canMove)
        {
            rigid.velocity = Vector3.zero;
        }


        if (anim.GetCurrentAnimatorStateInfo(0).IsName("Dash"))
        {
            //Debug.Log (rigid.velocity);

            if (rigid.velocity != Vector3.zero)
            {
                efect = true;
            }
            else
            {
                efect = false;
            }

            //	anim.SetFloat ("ComboAttack",0);
        }
        else
        {
            efect = false;
            //ps.Stop ();
        }
        if (efect)
        {
            ps.Play();
        }
        else
        {
            ps.Stop();
        }
    }
Example #9
0
 public Defense(CombatType type, int modifier)
 {
     Type     = type;
     Modifier = modifier;
 }
Example #10
0
 public SecondArmor(CombatType defense) : base(defense)
 {
 }
Example #11
0
 public ThirdArmor(CombatType defense) : base(defense)
 {
 }
Example #12
0
 public FirstArmor(CombatType defense) : base(defense)
 {
 }
Example #13
0
 public Attack(CombatType attackType, int damage)
 {
     this.damage     = damage;
     this.attackType = attackType;
 }
Example #14
0
 public PenetrableArmor(CombatType defense)
 {
     this.defense = defense;
 }
Example #15
0
 /// <summary>
 /// Called when a creature evades an attack
 /// </summary>
 public virtual void OnEvade(WorldObject attacker, CombatType attackType)
 {
     // empty base for non-player creatures?
 }
        public bool DoesModifierApply(IUnit candidate, IUnit opponent, IHexCell location, CombatType combatType)
        {
            if (Conditions.Count == 0)
            {
                return(true);
            }

            foreach (var condition in Conditions)
            {
                if (JoinedTogetherBy == JoinType.And && !condition.IsConditionMet(candidate, opponent, location, combatType))
                {
                    return(false);
                }
                else if (JoinedTogetherBy == JoinType.Or && condition.IsConditionMet(candidate, opponent, location, combatType))
                {
                    return(true);
                }
            }

            return(JoinedTogetherBy == JoinType.And ? true : false);
        }
Example #17
0
 /// <summary>
 /// Called when a creature hits a target
 /// </summary>
 public virtual void OnDamageTarget(WorldObject target, CombatType attackType, bool critical)
 {
     // empty base for non-player creatures?
 }
Example #18
0
 public GCombatEventArgs(CombatType type)
 {
     CombatType = type;
     Unit = new PUnit(uint.MinValue);
 }
Example #19
0
 public YAMLObject GetYAMLObject(CombatType type)
 {
     return(yamlReader.GetYAMLObject(@"YAML\Combats\" + type.ToString() + ".yml"));
 }
Example #20
0
 public GCombatEventArgs(CombatType type, PUnit unit)
 {
     CombatType = type;
     Unit = unit;
 }
Example #21
0
        protected override object this[string index]
        {
            get
            {
                #region
                switch (index)
                {
                case "CombatLogID": return(CombatLogID);

                case "UserID": return(UserID);

                case "CombatType": return(CombatType);

                case "CityID": return(CityID);

                case "PlotID": return(PlotID);

                case "NpcID": return(NpcID);

                case "HostileUser": return(HostileUser);

                case "CombatProcess": return(CombatProcess);

                case "PrizeItem": return(PrizeItem);

                case "IsWin": return(IsWin);

                case "CreateDate": return(CreateDate);

                default: throw new ArgumentException(string.Format("UserCombatLog index[{0}] isn't exist.", index));
                }
                #endregion
            }
            set
            {
                #region
                switch (index)
                {
                case "CombatLogID":
                    _CombatLogID = value.ToNotNullString();
                    break;

                case "UserID":
                    _UserID = value.ToNotNullString();
                    break;

                case "CombatType":
                    _CombatType = value.ToEnum <CombatType>();
                    break;

                case "CityID":
                    _CityID = value.ToInt();
                    break;

                case "PlotID":
                    _PlotID = value.ToInt();
                    break;

                case "NpcID":
                    _NpcID = value.ToInt();
                    break;

                case "HostileUser":
                    _HostileUser = value.ToNotNullString();
                    break;

                case "CombatProcess":
                    _CombatProcess = value.ToNotNullString();
                    break;

                case "PrizeItem":
                    _PrizeItem = ConvertCustomField <CacheList <PrizeItemInfo> >(value, index);
                    break;

                case "IsWin":
                    _IsWin = value.ToBool();
                    break;

                case "CreateDate":
                    _CreateDate = value.ToDateTime();
                    break;

                default: throw new ArgumentException(string.Format("UserCombatLog index[{0}] isn't exist.", index));
                }
                #endregion
            }
        }
Example #22
0
 public void AttackChoice()
 {
     combatType = bossCombat[currentPlayer] ? CombatType.BossAttack : CombatType.Attack;
     Combat();
 }
Example #23
0
 protected override object this[string index]
 {
     get
     {
         #region
         switch (index)
         {
             case "CombatLogID": return CombatLogID;
             case "UserID": return UserID;
             case "CombatType": return CombatType;
             case "CityID": return CityID;
             case "PlotID": return PlotID;
             case "NpcID": return NpcID;
             case "HostileUser": return HostileUser;
             case "CombatProcess": return CombatProcess;
             case "PrizeItem": return PrizeItem;
             case "IsWin": return IsWin;
             case "CreateDate": return CreateDate;
             default: throw new ArgumentException(string.Format("UserCombatLog index[{0}] isn't exist.", index));
         }
         #endregion
     }
     set
     {
         #region
         switch (index)
         {
             case "CombatLogID":
                 _CombatLogID = value.ToNotNullString();
                 break;
             case "UserID":
                 _UserID = value.ToNotNullString();
                 break;
             case "CombatType":
                 _CombatType = value.ToEnum<CombatType>();
                 break;
             case "CityID":
                 _CityID = value.ToInt();
                 break;
             case "PlotID":
                 _PlotID = value.ToInt();
                 break;
             case "NpcID":
                 _NpcID = value.ToInt();
                 break;
             case "HostileUser":
                 _HostileUser = value.ToNotNullString();
                 break;
             case "CombatProcess":
                 _CombatProcess = value.ToNotNullString();
                 break;
             case "PrizeItem":
                 _PrizeItem =ConvertCustomField<CacheList<PrizeItemInfo>>(value, index); 
                 break;
             case "IsWin":
                 _IsWin = value.ToBool();
                 break;
             case "CreateDate":
                 _CreateDate = value.ToDateTime();
                 break;
             default: throw new ArgumentException(string.Format("UserCombatLog index[{0}] isn't exist.", index));
         }
         #endregion
     }
 }
Example #24
0
 public void EvadeChoice()
 {
     combatType = bossCombat[currentPlayer] ? CombatType.BossEvade : CombatType.Evade;
     Combat();
 }
    //damage calculation from hit
    public void Hit(CombatType cType, float[] passedEleMulti, Element incDam, Element lessDam, float baseDam, GameObject attacker)
    {
        //Need: Attack type, armour type, ele multipliers, inc damage to, less damage to, attack or spell damage
        //if their attack type matches our armour type, halve damage bases
        baseDam *= AttackArmourMultiCalc(cType);
        //Double eleMultiplier for (their)inc damage to and (our)inc damage from and halve multiplier from (their)less damage to and (our)less damage from
        //% of each element(theirs)
        //% of each element(ours)
        float[] theirEleMulti = new float[4];
        float[] tempEleMulti = new float[4];
        for (int i = 0; i < tempEleMulti.Length; i++)
        {
            theirEleMulti[i] = passedEleMulti[i];
            theirEleMulti[i] /= 4;
            tempEleMulti[i] = eleMulti[i];
            tempEleMulti[i] /= 4;
        }
        //influence our resistance
        //increase damage
        if(incDam.name == "Air")
        {
            tempEleMulti[0] *= 2;
        }
        else if(incDam.name == "Earth")
        {
            tempEleMulti[1] *= 2;
        }
        else if (incDam.name == "Water")
        {
            tempEleMulti[2] *= 2;
        }
        else if (incDam.name == "Fire")
        {
            tempEleMulti[3] *= 2;
        }
        //less damage
        if (lessDam.name == "Air")
        {
            tempEleMulti[0] /= 2;
        }
        else if (lessDam.name == "Earth")
        {
            tempEleMulti[1] /= 2;
        }
        else if (lessDam.name == "Water")
        {
            tempEleMulti[2] /= 2;
        }
        else if (lessDam.name == "Fire")
        {
            tempEleMulti[3] /= 2;
        }
        //influence their damage
        //increase against our weakness
        if (incDamageFrom.name == "Air")
        {
            theirEleMulti[0] *= 2;
        }
        else if (incDamageFrom.name == "Earth")
        {
            theirEleMulti[1] *= 2;
        }
        else if (incDamageFrom.name == "Water")
        {
            theirEleMulti[2] *= 2;
        }
        else if (incDamageFrom.name == "Fire")
        {
            theirEleMulti[3] *= 2;
        }
        //reduce against our weakness
        if (lessDamageFrom.name == "Air")
        {
            theirEleMulti[0] /= 2;
        }
        else if (lessDamageFrom.name == "Earth")
        {
            theirEleMulti[1] /= 2;
        }
        else if (lessDamageFrom.name == "Water")
        {
            theirEleMulti[2] /= 2;
        }
        else if (lessDamageFrom.name == "Fire")
        {
            theirEleMulti[3] /= 2;
        }
        //Total up the damage they'll be dealing (average of their multiplier applied to base damage)
        //Total up our defence (average of our multiplier applied to base damage)
        float bonusDam = 0;
        float bonusResist = 0;
        for (int i = 0; i < tempEleMulti.Length; i++)
        {
            theirEleMulti[i] *= baseDam;
            tempEleMulti[i] *= defence;
            bonusDam += theirEleMulti[i];
            bonusResist += tempEleMulti[i];
        }
        bonusDam /= 4;
        bonusResist /= 4;

        int totalDamage = Mathf.Abs(Mathf.RoundToInt(bonusDam - bonusResist));
        //Debug.Log(totalDamage);
        health -= totalDamage;
        healthBar.fillAmount = ((float)health / 100.0f);

        if(combatType == CombatType.Defence && Vector3.Distance(transform.position, attacker.transform.position) < 2)
        {
            attackTarget = attacker;
            StartCoroutine("Attack");
        }
    }
Example #26
0
        private float DoCalculateDamage(Creature attacker, Creature defender, WorldObject damageSource)
        {
            var playerAttacker = attacker as Player;
            var playerDefender = defender as Player;

            Attacker = attacker;
            Defender = defender;

            CombatType = attacker.GetCombatType();

            DamageSource = damageSource;

            Weapon = attacker.GetEquippedWeapon();

            AttackType   = attacker.GetAttackType(Weapon, CombatManeuver);
            AttackHeight = attacker.AttackHeight ?? AttackHeight.Medium;

            // check lifestone protection
            if (playerDefender != null && playerDefender.UnderLifestoneProtection)
            {
                LifestoneProtection = true;
                playerDefender.HandleLifestoneProtection();
                return(0.0f);
            }

            if (defender.Invincible)
            {
                return(0.0f);
            }

            // evasion chance
            EvasionChance = GetEvadeChance(attacker, defender);
            if (EvasionChance > ThreadSafeRandom.Next(0.0f, 1.0f))
            {
                Evaded = true;
                return(0.0f);
            }

            // get base damage
            if (playerAttacker != null)
            {
                GetBaseDamage(playerAttacker, CombatManeuver);
            }
            else
            {
                GetBaseDamage(attacker, CombatManeuver);
            }

            if (GeneralFailure)
            {
                return(0.0f);
            }

            // get damage modifiers
            PowerMod     = attacker.GetPowerMod(Weapon);
            AttributeMod = attacker.GetAttributeMod(Weapon);
            SlayerMod    = WorldObject.GetWeaponCreatureSlayerModifier(attacker, defender);

            // ratings
            DamageRatingBaseMod = Creature.GetPositiveRatingMod(attacker.GetDamageRating());
            RecklessnessMod     = Creature.GetRecklessnessMod(attacker, defender);
            SneakAttackMod      = attacker.GetSneakAttackMod(defender);
            HeritageMod         = attacker.GetHeritageBonus(Weapon) ? 1.05f : 1.0f;

            DamageRatingMod = Creature.AdditiveCombine(DamageRatingBaseMod, RecklessnessMod, SneakAttackMod, HeritageMod);

            // damage before mitigation
            DamageBeforeMitigation = BaseDamage * AttributeMod * PowerMod * SlayerMod * DamageRatingMod;

            // critical hit?
            var attackSkill = attacker.GetCreatureSkill(attacker.GetCurrentWeaponSkill());

            CriticalChance = WorldObject.GetWeaponCritChanceModifier(attacker, attackSkill, defender);
            if (CriticalChance > ThreadSafeRandom.Next(0.0f, 1.0f))
            {
                var criticalDefended = false;
                if (playerDefender != null && playerDefender.AugmentationCriticalDefense > 0)
                {
                    var criticalDefenseMod    = playerAttacker != null ? 0.05f : 0.25f;
                    var criticalDefenseChance = playerDefender.AugmentationCriticalDefense * criticalDefenseMod;

                    if (criticalDefenseChance > ThreadSafeRandom.Next(0.0f, 1.0f))
                    {
                        criticalDefended = true;
                    }
                }

                if (!criticalDefended)
                {
                    IsCritical = true;

                    CriticalDamageMod = 1.0f + WorldObject.GetWeaponCritDamageMod(attacker, attackSkill, defender);

                    // recklessness excluded from crits
                    RecklessnessMod        = 1.0f;
                    DamageRatingMod        = Creature.AdditiveCombine(DamageRatingBaseMod, SneakAttackMod, HeritageMod);
                    DamageBeforeMitigation = BaseDamageMod.MaxDamage * AttributeMod * PowerMod * SlayerMod * DamageRatingMod * CriticalDamageMod;
                }
            }

            // Armor Rending reduces physical armor too?
            var armorRendingMod = 1.0f;

            if (Weapon != null && Weapon.HasImbuedEffect(ImbuedEffectType.ArmorRending))
            {
                armorRendingMod = WorldObject.GetArmorRendingMod(attackSkill);
            }

            // get body part / armor pieces / armor modifier
            if (playerDefender != null)
            {
                // select random body part @ current attack height
                GetBodyPart(AttackHeight);

                // get player armor pieces
                Armor = attacker.GetArmorLayers(playerDefender, BodyPart);

                // get armor modifiers
                ArmorMod = attacker.GetArmorMod(DamageType, Armor, Weapon, armorRendingMod);
            }
            else
            {
                // select random body part @ current attack height
                GetBodyPart(AttackHeight, defender);
                if (Evaded)
                {
                    return(0.0f);
                }

                Armor = CreaturePart.GetArmorLayers((CombatBodyPart)BiotaPropertiesBodyPart.Key);

                // get target armor
                ArmorMod = CreaturePart.GetArmorMod(DamageType, Armor, Weapon, armorRendingMod);
            }

            if (Weapon != null && Weapon.HasImbuedEffect(ImbuedEffectType.IgnoreAllArmor))
            {
                ArmorMod = 1.0f;
            }

            // get resistance modifiers
            WeaponResistanceMod = WorldObject.GetWeaponResistanceModifier(attacker, attackSkill, DamageType);

            if (playerDefender != null)
            {
                ResistanceMod = playerDefender.GetResistanceMod(DamageType, Weapon, WeaponResistanceMod);
            }
            else
            {
                var resistanceType = Creature.GetResistanceType(DamageType);
                ResistanceMod = (float)defender.GetResistanceMod(resistanceType, Weapon, WeaponResistanceMod);
            }

            // damage resistance rating
            DamageResistanceRatingMod = Creature.GetNegativeRatingMod(defender.GetDamageResistRating(CombatType));

            // get shield modifier
            ShieldMod = defender.GetShieldMod(attacker, DamageType, Weapon);

            // calculate final output damage
            Damage          = DamageBeforeMitigation * ArmorMod * ShieldMod * ResistanceMod * DamageResistanceRatingMod;
            DamageMitigated = DamageBeforeMitigation - Damage;

            return(Damage);
        }
Example #27
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="userID">玩家ID</param>
        /// <param name="magicID">使用的阵形</param>
        /// <param name="inspirePercent">鼓舞加成</param>
        /// <param name="combatType">战斗类型</param>
        public UserEmbattleQueue(string userID, int magicID, double inspirePercent, CombatType combatType)
        {
            inspirePercent = MathUtils.Addition(inspirePercent, CombatHelper.InspirePercentEffect(userID), double.MaxValue); //使用战力道具后的战力
            _userID = userID;
            _magicID = magicID;
            _combatType = combatType;
            //修复玩家开启的阵法与GameUser中的阵法ID不同
            GameUser userInfo = new GameDataCacheSet<GameUser>().FindKey(userID);
            if (userInfo != null)
            {
                var magicsArray = new GameDataCacheSet<UserMagic>().FindAll(userID, m => m.MagicType == MagicType.MoFaZhen && m.IsEnabled);
                if (magicsArray.Count > 0 && userInfo.UseMagicID != magicsArray[0].MagicID)
                {
                    userInfo.UseMagicID = magicsArray[0].MagicID;
                    //userInfo.Update();
                    _magicID = magicsArray[0].MagicID;
                }
            }
            embattleList = new GameDataCacheSet<UserEmbattle>().FindAll(userID, m => m.MagicID == magicID);

            short replacePotion = GeneralReplaceAttack.CheckReplacePostion(userID);

            HashSet<int> generalHash = new HashSet<int>();
            foreach (UserEmbattle embattle in embattleList)
            {
                //wuzf 8-18 修复多个相同佣兵阵形数据
                if (embattle.GeneralID == 0) continue;
                if (generalHash.Contains(embattle.GeneralID))
                {
                    embattle.GeneralID = 0;
                    //embattle.Update();
                    continue;
                }
                else
                {
                    generalHash.Add(embattle.GeneralID);
                }
                int index = embattle.Position - 1;
                IGeneral general = Create(embattle, inspirePercent, replacePotion);
                if (general != null && general.ReplacePosition > 0)
                {
                    index = general.Position - 1;
                }
                SetQueue(index, general);
                this.PriorityNum += PriorityHelper.GeneralTotalPriority(embattle.UserID, embattle.GeneralID);
            }

            if (embattleList.Count == 0)
            {
                new BaseLog().SaveLog(new Exception(string.Format("加载玩家阵形异常UserId:{0},magicID:{1}", userID, magicID)));
            }
        }
Example #28
0
 public Combat(int idType, string name, Sprite icon, GameObject model, Dictionary <int, int> cost, float attack, float defense, float walkSpeed, float lifeTotal, float range, float attackSpeed, CombatType combatType, float trainingTime, int visionField) : base(idType, name, icon, model, cost, attack, defense, walkSpeed, lifeTotal, range, attackSpeed, trainingTime, visionField)
 {
     this.combatType = combatType;
 }