예제 #1
0
파일: HookUnit.cs 프로젝트: FoKycHuK/CVARC
        public UnitResponse ProcessCommand(object _command)
        {
            if (actor.IsDisabled)
            {
                return(UnitResponse.Denied());
            }

            if (hook.IsThrown)
            {
                hook.Pudge.ActivateBuff(PudgeEvent.HookThrown, hook.Pudge.Rules.HookThrown);
                return(UnitResponse.Accepted(0.1));
            }

            var command = Compatibility.Check <IHookCommand>(this, _command);

            if (command.MakeHook && !hook.Pudge.IsBuffActivated(PudgeEvent.HookCooldown))
            {
                if (hook.IsAvailable && actor.World.Configuration.LoadingData.Level != "Level1")
                {
                    Hook();
                }

                return(UnitResponse.Accepted(0.1));
            }

            return(UnitResponse.Denied());
        }
예제 #2
0
        public UnitResponse ProcessCommand(object command)
        {
            var order = Compatibility.Check <IArmyInterfaceCommand>(this, command).HireOrder;

            if (order == null)
            {
                return(UnitResponse.Denied());
            }

            if (actor.IsDead)
            {
                return(UnitResponse.Accepted(HommRules.Current.UnitsHireDuration));
            }

            actor.World.HommEngine.Freeze(actor.ControllerId);
            actor.World.HommEngine.SetAnimation(actor.ControllerId, Animation.Idle);

            order.Apply(actor.Player);

            Debugger.Log($"{actor.ControllerId} resources:");

            foreach (var kv in actor.Player.Resources)
            {
                Debugger.Log($"{kv.Key} - {kv.Value}");
            }

            Debugger.Log($"{actor.ControllerId} army:");

            foreach (var kv in actor.Player.Army)
            {
                Debugger.Log($"{kv.Key} - {kv.Value}");
            }

            return(UnitResponse.Accepted(HommRules.Current.UnitsHireDuration));
        }
예제 #3
0
        public UnitResponse ProcessCommand(object command)
        {
            var scoutOrder = Compatibility.Check <IScoutCommand>(this, command).ScoutOrder;

            if (scoutOrder == null)
            {
                return(UnitResponse.Denied());
            }

            if (!scoutOrder.ScoutHero ^ scoutOrder.ScoutTile)
            {
                throw new ArgumentException("Please scout either hero or tile at one time.");
            }

            if (scoutOrder.ScoutTile && !scoutOrder.TileToScout.ToLocation().IsInside(actor.Map.Size))
            {
                throw new ArgumentException("Tile to scout is out of map bounds.");
            }

            if (!actor.Player.Scout.IsAvailable())
            {
                throw new InvalidOperationException("Scouting is not available at a time. " +
                                                    "Please wait `HommRules.ScoutingCooldown` before sending a new scout.");
            }

            return(UnitResponse.Accepted(actor.Player.Scout.Execute(scoutOrder)));
        }
        public static UnitResponse ToModel(this UnitDTO unit)
        {
            UnitResponse model = new UnitResponse();

            model.Id         = unit.Id;
            model.Area       = unit.Area;
            model.UnitNumber = unit.UnitNumber;
            return(model);
        }
예제 #5
0
        public UnitResponse ProcessCommand(object command)
        {
            var order = Compatibility.Check <IArmyInterfaceCommand>(this, command).Order;

            if (order == null)
            {
                return(UnitResponse.Denied());
            }

            order.Apply(actor.Player);

            return(UnitResponse.Accepted(HommRules.Current.BuyDuration));
        }
예제 #6
0
        public UnitResponse ProcessCommand(object _command)
        {
            if (actor.IsDisabled)
            {
                return(UnitResponse.Denied());
            }
            var command = Compatibility.Check <IDaggerCommand>(this, _command);

            if (command.MakeDagger)
            {
                actor.Dagger(command.DaggerDestination);
                return(UnitResponse.Accepted(0.1));
            }
            return(UnitResponse.Denied());
        }
예제 #7
0
파일: WardUnit.cs 프로젝트: FoKycHuK/CVARC
        public UnitResponse ProcessCommand(object _command)
        {
            if (actor.IsDisabled)
            {
                return(UnitResponse.Denied());
            }
            var command = Compatibility.Check <IWardCommand>(this, _command);

            if (command.MakeWard)
            {
                actor.SpawnWard();
                return(UnitResponse.Accepted(0.1));
            }
            return(UnitResponse.Denied());
        }
예제 #8
0
        public UnitResponse ProcessCommand(object _command)
        {
            var movement = Compatibility.Check <IHexMovCommand>(this, _command).Movement;

            if (movement == null)
            {
                return(UnitResponse.Denied());
            }

            var commandDuration = rules.MovementDuration * actor.VelocityModifier;

            actor.World.Clocks.AddTrigger(new OneTimeTrigger(commandDuration,
                                                             () => actor.Location = movement.Turn(actor.Location)));

            return(UnitResponse.Accepted(commandDuration));
        }
예제 #9
0
        public UnitResponse ProcessCommand(object command)
        {
            var movement = Compatibility.Check <IHexMovCommand>(this, command).Movement;

            if (movement == null)
            {
                return(UnitResponse.Denied());
            }

            var movementResult = movement.TryMoveHero(
                actor.World.HommEngine, actor.Player, actor.World.Round.Map);

            var newLocation      = movementResult.Item1;
            var movementDuration = movementResult.Item2;

            actor.World.Clocks.AddTrigger(actor.LocationTrigger = new LocationTrigger(
                                              actor.World.Clocks.CurrentTime, movementDuration / 2, actor, newLocation));

            return(UnitResponse.Accepted(double.PositiveInfinity));
        }
예제 #10
0
        public UnitResponse ProcessCommand(object command)
        {
            var armyForGarrison = Compatibility.Check <IGarrisonCommand>(this, command).WaitInGarrison;

            if (armyForGarrison == null)
            {
                return(UnitResponse.Denied());
            }

            if (actor.IsDead)
            {
                return(UnitResponse.Accepted(HommRules.Current.GarrisonBuildDuration));
            }

            actor.World.HommEngine.Freeze(actor.ControllerId);
            actor.World.HommEngine.SetAnimation(actor.ControllerId, Animation.Idle);

            if (!CheckCommandCorrect(armyForGarrison))
            {
                return(UnitResponse.Accepted(HommRules.Current.GarrisonBuildDuration));
            }

            TakeUnitsAway(actor.Player, armyForGarrison);

            var garrison = FindGarrison(actor.Player.Location);

            if (garrison == null)
            {
                garrison = CreateGarrison(armyForGarrison, actor.Player);
            }
            else
            {
                garrison.Populate(armyForGarrison);
            }

            Debug(garrison);

            return(UnitResponse.Accepted(HommRules.Current.GarrisonBuildDuration));
        }
예제 #11
0
파일: WADUnit.cs 프로젝트: FoKycHuK/CVARC
        public UnitResponse ProcessCommand(object _command)
        {
            if (actor.IsDisabled)
            {
                return(UnitResponse.Denied());
            }
            var command = Compatibility.Check <IGameCommand>(this, _command).GameMovement;

            if (command == null)
            {
                return(UnitResponse.Denied());
            }

            var hasteFactor = actor.HasteFactor;
            var eps         = 0.01;

            if (command.Range <= 0 && Math.Abs(command.Angle) < eps && command.WaitTime <= 0)
            {
                Wait();
                return(UnitResponse.Accepted(1));
            }
            if (command.WaitTime > eps)
            {
                Wait();
                return(UnitResponse.Accepted(command.WaitTime));
            }
            if (command.Range > eps)
            {
                var movementTime = Move(command.Range, hasteFactor);
                return(UnitResponse.Accepted(movementTime));
            }
            if (Math.Abs(command.Angle) > eps)
            {
                var rotationTime = Rotate(command.Angle);
                return(UnitResponse.Accepted(rotationTime));
            }
            return(UnitResponse.Accepted(0.025));
        }
예제 #12
0
        public UnitResponse ProcessCommand(object command)
        {
            Debugger.Log("Enter process command");

            var movement = Compatibility.Check <IHexMovCommand>(this, command).Movement;

            if (movement == null)
            {
                return(UnitResponse.Denied());
            }
            Debugger.Log("Accepted HexMovCommand");

            if (actor.IsDead)
            {
                return(UnitResponse.Accepted(movement.WaitDuration > 0
                    ? movement.WaitDuration
                    : HommRules.Current.MovementDuration));
            }

            var movementDuration = movement.Apply(actor);

            return(UnitResponse.Accepted(movementDuration + 0.001));
        }