Beispiel #1
0
        //Actions
        public bool TryGetAction(UseActionButton useButton, out UseAction action)
        {
            int maxPriority            = int.MinValue;
            int maxPriorityActionIndex = -1;

            if (availableActions.ContainsKey(useButton))
            {
                for (int i = 0; i < availableActions[useButton].Count; i++)
                {
                    var curAction = availableActions[useButton][i];
                    if (curAction.AvailableForChar(this) && curAction.Priority > maxPriority)
                    {
                        //action = availableActions[useButton][i];
                        maxPriorityActionIndex = i;
                        maxPriority            = curAction.Priority;
                    }
                }
            }
            if (maxPriorityActionIndex != -1)
            {
                action = availableActions[useButton][maxPriorityActionIndex];
                return(true);
            }
            else
            {
                action = null;
                return(false);
            }
        }
Beispiel #2
0
 private bool RemoveAction(UseAction action)
 {
     if (availableActions.ContainsKey(action.actionButton))
     {
         return(availableActions[action.actionButton].Remove(action));
     }
     return(false);
 }
Beispiel #3
0
 public static void Setup(UseAction use)
 {
     use(async(env, next) =>
     {
         var stream = (Stream)env["owin.ResponseBody"];
         await stream.WriteAsync("<h1>OWIN!</h1>");
         env["owin.ResponseStatusCode"] = 200;
     });
 }
Beispiel #4
0
        public void RemoveDestroyedAction(UseAction action)
        {
            bool removed = RemoveAction(action);

            if (isHauling && action == currentlyHauling)
            {
                ship.RemoveDependentTransform(action.transform);
            }
        }
Beispiel #5
0
        public void TestUseAction()
        {
            ActionFactory factory = new ActionFactory();

            factory.IsDraft = false;

            UseAction action = factory.CreateGameAction("USE 0 -1") as UseAction;

            Assert.IsNotNull(action);
            Assert.IsInstanceOfType(action, typeof(UseAction));
        }
Beispiel #6
0
 public PlayerCharacter(string name, int level, int experience) : base(name)
 {
     EquipedWeapon  = null;
     EquipedArmor   = null;
     Level          = level;
     Experience     = experience;
     this.HitPoints = MaxHitPoints;
     AddActionToList(MoveAction.GetActionBuilder());
     AddActionToList(UseAction.GetActionBuilder());
     AddActionToList(EquipAction.GetActionBuilder());
 }
Beispiel #7
0
        // override bool IsPlayer{get{return true;}set{}}

        public PlayerCharacter(string Name) : base(Name)
        {
            Experience     = 0;
            EquipedWeapon  = null;
            EquipedArmor   = null;
            this.HitPoints = MaxHitPoints;

            AddActionToList(MoveAction.GetActionBuilder());
            AddActionToList(UseAction.GetActionBuilder());
            AddActionToList(EquipAction.GetActionBuilder());
        }
Beispiel #8
0
 private void AddAction(UseAction action)
 {
     if (!availableActions.ContainsKey(action.actionButton))
     {
         availableActions.Add(action.actionButton, new List <UseAction>());
     }
     if (!availableActions[action.actionButton].Contains(action))
     {
         availableActions[action.actionButton].Add(action);
     }
 }
Beispiel #9
0
        public static void Setup(UseAction use)
        {
            //use(HttpsOnly.Create());
            use(Statics.AddFileAlias("/index.html", "/")
                .AddFolder("/scripts")
                .AddFolder("/content")
                .AddFolder("/html")
                .AddFolder("/App"));

            use(Application.Run);
        }
Beispiel #10
0
 public override void UseRequest()
 {
     if (Data.CanBuy(LocalPlayer))
     {
         var action = new UseAction(this);
         GameManager.Instance.PlayerActionRequest(action);
     }
     else
     {
         OnErrorEvent.TriggerEvents("Not enough money"); // TODO
     }
 }
Beispiel #11
0
        public void Use_Invalid_BlueItem_Target_Creature()
        {
            int invalidSourceId = 0;
            int targetId        = 0;

            UseAction action = new UseAction(invalidSourceId, targetId);
            bool      result = action.Execute(player1, player2);

            Assert.IsTrue(result);
            Assert.AreEqual(DEFAULT_MY_HEALTH, player1.Data.Health);
            Assert.AreEqual(DEFAULT_OPP_HEALTH, player2.Data.Health);
        }
Beispiel #12
0
        private static Random random = new Random();  // Random number generator to make the dice appear more random

        public CombatTurnBased(LunchHourGames lhg, CombatSystem combatSystem)
        {
            this.lhg          = lhg;
            this.combatSystem = combatSystem;

            this.chooseAction  = new ChooseAction(lhg, combatSystem, this);
            this.moveAction    = new MoveAction(lhg, combatSystem, this);
            this.attackAction  = new AttackAction(lhg, combatSystem, this);
            this.useAction     = new UseAction(lhg, combatSystem, this);
            this.defendAction  = new DefendAction(lhg, combatSystem, this);
            this.endTurnAction = new EndTurnAction(lhg, combatSystem, this);

            currentAction = null;
            nextAction    = null;
        }
Beispiel #13
0
        private void RunUseActionCreatureTest(int sourceId, int targetId)
        {
            Card card = player1.Hand[sourceId];

            player1.Mana = card.Cost;

            int expectedMyHealth  = player1.Data.Health + card.MyHealthChange;
            int expectedOppHealth = player2.Data.Health + card.OppHealthChange;

            int expectedNextDraw   = player1.NextDrawSize + card.Draw;
            int expectedPlayerHand = player1.Hand.Count - 1;


            player1.Table.TryGetValue(targetId, out CombatCreature target);
            if (target == null)
            {
                player2.Table.TryGetValue(targetId, out target);
            }

            int expectedAttack  = target.Attack + (targetId == -1 ? 0 : card.Attack);
            int expectedDefense = target.Defense + (targetId == -1 ? 0 : card.Defense);

            Card expectedCard = target.Card.Clone();

            if (card.Type == 2)
            {
                expectedCard.RemoveAbils(card.Abils);
            }
            else if (card.Type == 1)
            {
                expectedCard.AddAbils(card.Abils);
            }

            UseAction action = new UseAction(sourceId, targetId);
            bool      result = action.Execute(player1, player2);

            Assert.IsTrue(result);
            Assert.AreEqual(expectedMyHealth, player1.Data.Health);
            Assert.AreEqual(expectedOppHealth, player2.Data.Health);
            Assert.AreEqual(expectedNextDraw, player1.NextDrawSize);
            Assert.AreEqual(expectedPlayerHand, player1.Hand.Count);
            Assert.AreEqual(expectedAttack, target.Attack);
            Assert.AreEqual(expectedDefense, target.Defense);
            Assert.AreEqual(expectedCard.Abils, target.Card.Abils);
        }
Beispiel #14
0
        private void RunInvalidUseActionTest(int sourceId, int targetId)
        {
            int expectedMyHealth   = player1.Data.Health;
            int expectedOppHealth  = player2.Data.Health;
            int expectedNextDraw   = player1.NextDrawSize;
            int expectedOppTable   = player2.Table.Count;
            int expectedPlayerHand = player1.Hand.Count;


            UseAction action = new UseAction(sourceId, targetId);
            bool      result = action.Execute(player1, player2);

            Assert.IsTrue(result);
            Assert.AreEqual(expectedMyHealth, player1.Data.Health);
            Assert.AreEqual(expectedOppHealth, player2.Data.Health);
            Assert.AreEqual(expectedNextDraw, player1.NextDrawSize);
            Assert.AreEqual(expectedPlayerHand, player1.Hand.Count);
            Assert.AreEqual(expectedOppTable, player2.Table.Count);
        }
Beispiel #15
0
        // Currently, each use effect is its own component. If we run into a case where we have too many effects, we can push the
        // effects into the usable component itself, similarly to status effects (though status effects are their own mess right now)
        // which would probably be better for building on.
        private static bool ResolveUse(UseAction action, EncounterState state)
        {
            var user = state.GetEntityById(action.ActorId);

            // This is another issue that'd be solved with a global Entity lookup - though not the removal part.
            Entity usable = null;

            if (action.FromInventory)
            {
                var userInventory = user.GetComponent <InventoryComponent>();
                usable = userInventory.StoredEntityById(action.UsableId);
                if (usable.GetComponent <UsableComponent>() == null)
                {
                    state.LogMessage(string.Format("{0} is not usable!", usable.EntityName), failed: true);
                    return(false);
                }
                else
                {
                    userInventory.RemoveEntity(usable);
                }
            }
            else
            {
                usable = state.GetEntityById(action.UsableId);
                if (usable.GetComponent <UsableComponent>() == null)
                {
                    state.LogMessage(string.Format("{0} is not usable!", usable.EntityName), failed: true);
                    return(false);
                }
                else
                {
                    state.RemoveEntity(usable);
                }
            }

            state.LogMessage(string.Format("{0} used {1}!", user.EntityName, usable.EntityName));

            ResolveUseEffects(user, usable, state);

            // We assume all items are single-use; this will change if I deviate from the reference implementation!
            usable.QueueFree();
            return(true);
        }
Beispiel #16
0
        private void RunUseActionPlayerTest(int sourceId, int targetId)
        {
            Card card = player1.Hand[sourceId];

            player1.Mana = card.Cost;

            int expectedMyHealth  = player1.Data.Health + card.MyHealthChange;
            int expectedOppHealth = player2.Data.Health + card.OppHealthChange + card.Defense;

            int expectedNextDraw   = player1.NextDrawSize + card.Draw;
            int expectedPlayerHand = player1.Hand.Count - 1;

            UseAction action = new UseAction(sourceId, targetId);
            bool      result = action.Execute(player1, player2);

            Assert.IsTrue(result);
            Assert.AreEqual(expectedMyHealth, player1.Data.Health);
            Assert.AreEqual(expectedOppHealth, player2.Data.Health);
            Assert.AreEqual(expectedNextDraw, player1.NextDrawSize);
            Assert.AreEqual(expectedPlayerHand, player1.Hand.Count);
        }
Beispiel #17
0
 public virtual void DismissAction(UseAction action)
 {
     action.OnExitAction(charController);
 }
        public virtual void Use(Pawn worker)
        {
            if (!this.CanUseNow)
            {
                Log.Error("Used while CanUseNow is false");
            }
            float vision    = Props.visionRangeProvide;
            float detection = Props.detectionRangeProvide;

            //Light Level
            if (Props.NotUsableUnderDarkness && this.parent.Map.skyManager.CurSkyGlow <= 0.3)
            {
                if (useSearchlight && PowerOnOrDontNeedPower)
                {
                    vision    *= 0.6f;
                    detection *= 0.6f;
                }
                else
                {
                    vision = detection = 0f;
                }
            }
            //Pawn Sight
            if (Props.AffectedByOperatorSightAbility)
            {
                float sightFactor = worker.health.capacities.GetLevel(PawnCapacityDefOf.Sight);
                vision    *= sightFactor;
                detection *= sightFactor;
            }
            //Power
            if (!PowerOnOrDontNeedPower)
            {
                vision    *= 0.5f;
                detection *= 0.5f;
            }
            //Telescope
            if (useTelescope)
            {
                vision    *= 1.5f;
                detection *= 1.5f;
            }
            //Weather
            var weather = parent.Map.weatherManager.curWeather;

            if (Props.AffectedByWeather)
            {
                float factor = 1f;
                if (weather == PESDefOf.Fog)
                {
                    factor = 0.5f;
                }
                if (weather == PESDefOf.Rain)
                {
                    factor = 0.8f;
                }
                if (weather == PESDefOf.FoggyRain)
                {
                    factor = 0.4f;
                }
                if (weather == PESDefOf.RainyThunderstorm)
                {
                    factor = 0.7f;
                }
                if (weather == PESDefOf.SnowHard)
                {
                    factor = 0.9f;
                }
                vision    *= factor;
                detection *= factor;
            }
            UseAction?.Invoke(worker);
            this.UpdateDetectionAbility(Mathf.RoundToInt(vision), Mathf.RoundToInt(detection));
        }
 public static void Setup(UseAction use)
 {
     use(Application.App);
 }
Beispiel #20
0
        public void UseRequest()
        {
            var action = new UseAction(this);

            GameManager.Instance.PlayerActionRequest(action);
        }
Beispiel #21
0
 public UseActionTest()
 {
     action         = new UseAction();
     controllerMock = new Mock <IGameController>();
 }
Beispiel #22
0
        public static void Setup(UseAction use)
        {
            var requestPrinter = new RequestPrinter();

            use(requestPrinter.PrintRequest);
        }
 /// <summary>
 /// Called by Fix to let you set up your application
 /// </summary>
 /// <param name="use">Function to add middleware or apps to the pipeline.</param>
 /// <param name="map">Function to add middleware or apps only for URLs with a certain prefix.</param>
 /// <remarks>We have to use the <c>map</c> function to restrict SignalR otherwise it goes batshit and complains about protocols in every response.</remarks>
 public void Setup(UseAction use, MapAction map)
 {
     map("/signalr", OwinSignalR.Hub(_startupEnv));
     use(Statics.AddFileAlias("/index.html", "/").AddFolder("/Scripts"));
 }
Beispiel #24
0
 public static void Setup(UseAction use)
 {
     use(Application.Run);
 }
 /// <summary>
 /// Called by Fix to let you set up your application
 /// </summary>
 /// <param name="use">Function to add middleware or apps to the pipeline.</param>
 /// <param name="map">Function to add middleware or apps only for URLs with a certain prefix.</param>
 /// <remarks>We have to use the <c>map</c> function to restrict SignalR otherwise it goes batshit and complains about protocols in every response.</remarks>
 public void Setup(UseAction use, MapAction map)
 {
     map("/signalr", OwinSignalR.Hub(_startupEnv));
     use(Statics.AddFileAlias("/index.html", "/").AddFolder("/Scripts"));
 }
Beispiel #26
0
 public virtual void ExecuteAction(UseAction action)
 {
     action.DoAction(charController);
 }