コード例 #1
0
ファイル: LaunchEvent.cs プロジェクト: naib864/Remake-Core
        public static LaunchEvent FromJson(string jsonString)
        {
            DeserializedLaunchEvent parsed = JsonConvert.DeserializeObject <DeserializedLaunchEvent>(jsonString);

            GameTick currentTick = Game.TimeMachine.GetCurrentTick();
            GameTick eventTick   = GameTick.FromTickNumber(parsed.GameTick);

            // Go to the time the event occurred.
            Game.TimeMachine.GoTo(eventTick);
            GameState state = Game.TimeMachine.GetState();

            ILaunchable source = state.GetOutpostById(parsed.Source);

            if (source == null)
            {
                source = state.GetSubById(parsed.Source);
            }

            ICombatable destination = state.GetOutpostById(parsed.Destination);

            if (destination == null)
            {
                destination = state.GetSubById(parsed.Destination);
            }

            Game.TimeMachine.GoTo(currentTick);

            return(new LaunchEvent(eventTick, source, parsed.Drillers, destination));
        }
コード例 #2
0
        public override async Task <DougResponse> Activate(User user, ICombatable target, string channel)
        {
            if (!CanActivateSkill(user, out var response))
            {
                return(response);
            }

            if (target == null)
            {
                return(new DougResponse());
            }

            if (target is User targetUser)
            {
                var channelType = _channelRepository.GetChannelType(channel);
                if (channelType != ChannelType.Common && channelType != ChannelType.Pvp)
                {
                    return(new DougResponse(DougMessages.NotInRightChannel));
                }

                var usersInChannel = await _slack.GetUsersInChannel(channel);

                if (usersInChannel.All(usr => usr != targetUser.Id))
                {
                    return(new DougResponse(DougMessages.UserIsNotInPvp));
                }

                response = await StealFromUser(user, targetUser, channel);
            }

            return(response);
        }
コード例 #3
0
ファイル: Specialist.cs プロジェクト: jousle/Remake-Core
 /// <summary>
 /// Reverses a specialist effect to a friendly and enemy combatable
 /// </summary>
 /// <param name="friendly">The friendly combatable to reverse effects to</param>
 /// <param name="enemy">The enemy combatable to reverse effects to</param>
 public void UndoEffect(ICombatable friendly, ICombatable enemy)
 {
     foreach (ISpecialistEffect effect in this._specialistEffects)
     {
         effect.BackwardEffect(friendly, enemy);
     }
 }
コード例 #4
0
        protected virtual bool CanActivateSkill(User user, ICombatable target, string channel, out DougResponse response)
        {
            var totalCooldown = Cooldown * (1 - user.CooldownReduction());

            if (!user.HasWeaponType(RequiredWeapon) && RequiredWeapon != null)
            {
                response = new DougResponse(string.Format(DougMessages.WrongWeaponForSkill, RequiredWeapon.Name));
                return(false);
            }

            if (user.IsSkillOnCooldown())
            {
                response = new DougResponse(string.Format(DougMessages.CommandOnCooldown, user.CalculateStealCooldownRemaining()));
                return(false);
            }

            if (!user.HasEnoughEnergyForCost(EnergyCost))
            {
                response = new DougResponse(DougMessages.NotEnoughEnergy);
                return(false);
            }

            user.Energy -= EnergyCost;
            StatsRepository.FireSkill(user.Id, TimeSpan.FromSeconds(totalCooldown), user.Energy);
            response = new DougResponse();
            return(true);
        }
コード例 #5
0
    public void Fight(ICombatable attacker, ICombatable defender)
    {
        int damage = CalculateAttackerDamage(attacker, defender);

        attacker.OnAttack(defender);
        attacker.CurrentActionPoints -= attacker.AttackActionPointCost;
        defender.CurrentHealth       -= damage;

        if (defender.CurrentHealth <= 0)
        {
            defender.OnDeath();
        }
        else if (defender.CanRetaliate())
        {
            int dist = HexHeuristic.MinDistTile(defender.Tile, attacker.Tile);
            if (dist > defender.Range)
            {
                return;
            }

            damage = CalculateDefenderDamage(defender);
            defender.OnAttack(attacker);
            attacker.CurrentHealth -= damage;
            if (attacker.CurrentHealth <= 0)
            {
                attacker.OnDeath();
            }
        }
    }
コード例 #6
0
        internal static void Resolve(ICombatable attacking, ICombatable defending)
        {
            var combatResult = Resolve(new ArmiesPair(attacking.Army, defending.Army));

            attacking.SetArmy(combatResult.AttackingArmy);
            defending.SetArmy(combatResult.DefendingArmy);
        }
コード例 #7
0
        public void CreateArmy(ICombatable army, Location location)
        {
            var armyType = GetArmyType(army);

            engine.CreateObject(army.UnityId, armyType, location.X, location.Y);
            engine.SetRotation(army.UnityId, random.ChoiceWithProbability(0.5, Mathf.PI / 3, 2 * Mathf.PI / 3));
        }
コード例 #8
0
        protected override bool CanActivateSkill(User user, ICombatable target, string channel, out DougResponse response)
        {
            var totalCooldown = Cooldown * (1 - user.CooldownReduction());

            if (target is User targetUser)
            {
                var usersInChannel = _slack.GetUsersInChannel(channel).Result;
                if (usersInChannel.All(usr => usr != targetUser.Id))
                {
                    response = new DougResponse(DougMessages.UserNotInChannel);
                    return(false);
                }
            }

            if (user.IsSkillOnCooldown())
            {
                response = new DougResponse(string.Format(DougMessages.CommandOnCooldown, user.CalculateStealCooldownRemaining()));
                return(false);
            }

            if (!user.HasEnoughEnergyForCost(EnergyCost))
            {
                response = new DougResponse(DougMessages.NotEnoughEnergy);
                return(false);
            }

            user.Energy -= EnergyCost;
            StatsRepository.FireSkill(user.Id, TimeSpan.FromSeconds(totalCooldown), user.Energy);
            response = new DougResponse();
            return(true);
        }
コード例 #9
0
ファイル: Heal.cs プロジェクト: WilliamGF/Doug
        public override DougResponse Activate(User user, ICombatable target, string channel)
        {
            if (!CanActivateSkill(user, out var response))
            {
                return(response);
            }

            var userToBeHealed = user;

            if (target != null && target is User targetUser)
            {
                userToBeHealed = targetUser;
            }

            var healAmount = 30; // TODO : add scaling

            userToBeHealed.Health += healAmount;
            StatsRepository.UpdateHealth(userToBeHealed.Id, userToBeHealed.Health);

            var message = string.Format(DougMessages.UserHealed, _userService.Mention(user), _userService.Mention(userToBeHealed), healAmount);

            _slack.BroadcastMessage(message, channel);

            return(new DougResponse());
        }
コード例 #10
0
        public bool BackwardAction(TimeMachine timeMachine, GameState state)
        {
            if (!_eventSuccess)
            {
                return(false);
            }

            List <Specialist> specialists = new List <Specialist>();

            specialists.AddRange(_combatant1Specialists);
            specialists.AddRange(_combatant2Specialists);

            while (specialists.Count > 0)
            {
                Specialist lowPriority = null;
                foreach (Specialist s in specialists)
                {
                    if (lowPriority == null || s.GetPriority() >= lowPriority.GetPriority())
                    {
                        lowPriority = s;
                    }
                }
                // Apply the specialist effect to the enemey.
                ICombatable enemy    = _combatant1.GetOwner() == lowPriority.GetOwner() ? _combatant2 : _combatant1;
                ICombatable friendly = _combatant1.GetOwner() == lowPriority.GetOwner() ? _combatant1 : _combatant2;
                lowPriority.UndoEffect(friendly, enemy);
            }
            return(true);
        }
コード例 #11
0
        public bool ForwardAction(TimeMachine timeMachine, GameState state)
        {
            this._combatant1Specialists = _combatant1.GetSpecialistManager().GetSpecialists();
            this._combatant2Specialists = _combatant1.GetSpecialistManager().GetSpecialists();

            List <Specialist> specialists = new List <Specialist>();

            specialists.AddRange(_combatant1.GetSpecialistManager().GetSpecialists());
            specialists.AddRange(_combatant2.GetSpecialistManager().GetSpecialists());

            while (specialists.Count > 0)
            {
                Specialist topPriority = null;
                foreach (Specialist s in specialists)
                {
                    // If any of the specialists are invalid, cancel the event.
                    if (!Validator.ValidateSpecialist(s))
                    {
                        this._eventSuccess = false;
                        return(false);
                    }
                    if (topPriority == null || s.GetPriority() < topPriority.GetPriority())
                    {
                        topPriority = s;
                    }
                }
                // Apply the specialist effect to the enemey.
                ICombatable enemy    = _combatant1.GetOwner() == topPriority.GetOwner() ? _combatant2 : _combatant1;
                ICombatable friendly = _combatant1.GetOwner() == topPriority.GetOwner() ? _combatant1 : _combatant2;
                topPriority.ApplyEffect(friendly, enemy);
            }
            return(true);
        }
コード例 #12
0
ファイル: Specialist.cs プロジェクト: jousle/Remake-Core
 /// <summary>
 /// Applies the specialist's effects to a friendly and enemy combatable.
 /// </summary>
 /// <param name="friendly">The friendly combatable to effect</param>
 /// <param name="enemy">The enemy combatable to effect</param>
 public void ApplyEffect(ICombatable friendly, ICombatable enemy)
 {
     foreach (ISpecialistEffect effect in this._specialistEffects)
     {
         effect.ForwardEffect(friendly, enemy);
     }
 }
コード例 #13
0
        public string Defend(ICombatable subject)
        {
            int defendValue = maxLevel - subject.Level;

            this.Health = -defendValue;

            return("Defending.");
        }
コード例 #14
0
        public override int OnAttacking(User attacker, ICombatable target, int damage)
        {
            attacker.Health += (int)(damage * 0.05);

            _statsRepository.UpdateHealth(attacker.Id, attacker.Health);

            return(base.OnAttacking(attacker, target, damage));
        }
コード例 #15
0
 /// <summary>
 /// Constructor for the combat event
 /// </summary>
 /// <param name="combatant1">The first combatant</param>
 /// <param name="combatant2">The second combatant</param>
 /// <param name="tick">The tick the combat occurs</param>
 /// <param name="combatLocation">The location of the combat</param>
 public CombatEvent(ICombatable combatant1, ICombatable combatant2, GameTick tick, RftVector combatLocation)
 {
     this._combatant1     = combatant1;
     this._combatant2     = combatant2;
     this._eventTick      = tick;
     this._combatLocation = combatLocation;
     this.EventName       = "Combat Event";
 }
コード例 #16
0
 // Use this for initialization
 void Start()
 {
     m_combatable = GetComponent <ICombatable>();
     m_timer      = new Timer(1f, true, () => {
         m_timer.ResetTimer();
         m_combatable.CombatStats.Shields += m_combatable.CombatStats.ShieldRegen;
     });
 }
コード例 #17
0
ファイル: LaunchEvent.cs プロジェクト: naib864/Remake-Core
 /// <summary>
 /// Constructor for a sub launch event.
 /// </summary>
 /// <param name="launchTime">The time of the launch</param>
 /// <param name="source">The source</param>
 /// <param name="drillerCount">The number of drillers to send</param>
 /// <param name="destination">The destination</param>
 public LaunchEvent(GameTick launchTime, ILaunchable source, int drillerCount, ICombatable destination)
 {
     this._launchTime   = launchTime;
     this._source       = source;
     this._drillerCount = drillerCount;
     this._destination  = destination;
     this.EventName     = "Launch Event";
 }
コード例 #18
0
ファイル: MovementHelper.cs プロジェクト: FoKycHuK/CVARC
 private double BeginCombat(ICombatable other, Tile robotTile, Tile otherTile)
 {
     return(new CombatHelper(robot).BeginCombat(other, robotTile, otherTile, () =>
     {
         robot.ControlTrigger.ScheduledTime = world.Clocks.CurrentTime + movementDuration + 0.001;
         MakeTurn(robot);
     }));
 }
コード例 #19
0
        public AttackedEventArgs(ICombatable attacker, ICombatable target, double rawDammage)
        {
            Attacker = attacker;

            Target = target;

            RawDammage = rawDammage;
        }
コード例 #20
0
ファイル: Unit.cs プロジェクト: v-free/hexMap
 public virtual void OnAttack(ICombatable target)
 {
     if (projectilePrefab != null)
     {
         Projectile instance  = Instantiate(projectilePrefab, transform.position, transform.rotation);
         Vector3    targetPos = new Vector3(target.PosX, target.PosY, target.PosZ);
         instance.Initialize(targetPos);
     }
 }
コード例 #21
0
        public async Task <DougResponse> ActivateSkill(User user, ICombatable target, string channel)
        {
            if (user.Loadout.Skillbook == null)
            {
                return(new DougResponse(DougMessages.NoSkillEquipped));
            }

            return(await user.Loadout.Skillbook.Activate(_skillFactory, user, target, channel));
        }
コード例 #22
0
 public override bool BackwardAction(TimeMachine timeMachine, GameState state)
 {
     if (EventSuccess)
     {
         ICombatable source = state.GetCombatableById(GetEventData().SourceId);
         source.GetShieldManager().ToggleShield();
     }
     return(EventSuccess);
 }
コード例 #23
0
ファイル: Combatable.cs プロジェクト: Whigle/PlayWaySchool
 public void ReceiveDamage(ICombatable damageDealer, float damage)
 {
     health -= damage;
     if (health <= 0)
     {
         Died?.Invoke(this);
         Destroy(this.gameObject);
     }
 }
コード例 #24
0
        public PhysicalAttack(ICombatable attacker, int minDamage, int maxDamage, int attackersHitrate, int attackersLuck) : base(RollAttack(minDamage, maxDamage), attacker)
        {
            AttackersHitrate = attackersHitrate;

            if (new Random().NextDouble() < Math.Sqrt(attackersLuck) * 0.04)
            {
                Status = AttackStatus.Critical;
            }
        }
コード例 #25
0
        public int OnCriticalHit(ICombatable attacker, ICombatable target, int damage, string channel)
        {
            if (attacker is User userAttacker)
            {
                damage = PropagateEffectEvents(userAttacker, damage, (damageSum, effect) => effect.OnCriticalHit(userAttacker, target, damageSum, channel));
            }

            return(damage);
        }
コード例 #26
0
ファイル: ICombatable.cs プロジェクト: niemandkun/homm
 public static bool HasNoArmy(this ICombatable c)
 {
     foreach (var stack in c.Army)
     {
         if (stack.Value > 0)
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #27
0
        public Attack AttackTarget(ICombatable target, IEventDispatcher eventDispatcher)
        {
            Attack attack = new PhysicalAttack(this, Monster.MinAttack, Monster.MaxAttack, Monster.Hitrate, Monster.GetCriticalHitChance(), 2, 0);

            if (Monster.DamageType == DamageType.Magical)
            {
                attack = new MagicAttack(this, Monster.MaxAttack);
            }

            return(target.ReceiveAttack(attack, eventDispatcher));
        }
コード例 #28
0
 public async Task DealDamage(User user, Attack attack, ICombatable target, string channel)
 {
     if (target is User targetUser)
     {
         await DealDamageToUser(user, attack, targetUser, channel);
     }
     else if (target is SpawnedMonster targetMonster)
     {
         await DealDamageToMonster(user, attack, targetMonster, channel);
     }
 }
コード例 #29
0
        public Attack AttackTarget(ICombatable target, IEventDispatcher eventDispatcher)
        {
            Attack attack = new PhysicalAttack(this, MinAttack, MaxAttack, Hitrate, Luck);

            if (DamageType == DamageType.Magical)
            {
                attack = new MagicAttack(this, Intelligence);
            }

            return(target.ReceiveAttack(attack, eventDispatcher));
        }
コード例 #30
0
        public PhysicalAttack(ICombatable attacker, int minDamage, int maxDamage, int attackersHitrate, double criticalHitChance, double criticalFactor, int pierce) : base(RollAttack(minDamage, maxDamage), attacker)
        {
            AttackersHitrate = attackersHitrate;
            CriticalFactor   = criticalFactor;
            Pierce           = pierce;

            if (new Random().NextDouble() < criticalHitChance)
            {
                Status = AttackStatus.Critical;
            }
        }