Пример #1
0
            public virtual void FillNextParameter(ActionTargetTileParameter ap = null)
            {
                if (toFill == null)
                {
                    toFill = CleanListOfParameters();
                }

                //if actor is a cpu controlled actor, do
                //ai fill params....

                if (prev != null)
                {
                    prev.StopListen();
                    prev.OnTargetTileChosen -= FillNextParameter;
                }


                if (toFill.Count > 0)
                {
                    ActionTargetTileParameter next = toFill [0];
                    if (OnWillFill != null)
                    {
                        OnWillFill(this, next);
                    }
                    toFill.RemoveAt(0);
                    next.OnTargetTileChosen += FillNextParameter;
                    prev = next;
                    next.Listen();
                }
                else
                {
                    CallOnParamsFilled();
                }
            }
Пример #2
0
            public Move(Actor actor) : base(actor)
            {
                cachedAoopLines = new List <LineRenderer> ();
                ActionTargetTileParameter placeToMove = new ActionTargetTileParameter(this, actor.MovesLeft());

                placeToMove.OnListen += (List <ATTile> potentialTargets) => {
                    //				MapManager.instance.ColorTiles (potentialTargets, new Color(0f, 0f, 1f, .3f));
                    foreach (ATTile t in potentialTargets)
                    {
                        //color blue
                        if (actor.GetComponent <TileMovement> ().TileHasEnemyReach(t))
                        {
                            t.PushShade(new Color(1f, 1f, .5f, .3f));
                        }
                        else
                        {
                            t.PushShade(new Color(0f, 0f, 1f, .30f));
                        }
                    }

                    //				if(MapManager.instance.TileUnderMouse() != null && !UIManager.instance.OverUI) {
                    //					MapManager.instance.StartCoroutine(DelayColorOverTiles());
                    //				}
                };


                placeToMove.OnStopListen += (List <ATTile> potentialTargets) => {
                    if (cachedPath != null)
                    {
                        MapManager.instance.UnColorTiles(cachedPath);
                    }

                    MapManager.instance.UnColorTiles(potentialTargets);
                    DestroyAOOPLines();
                    //				foreach(Tile t in potentialTargets) {
                    //					Debug.Log("stopped listening: " + t.name);
                    //				}
                };


                //color path grey on mouse over
                placeToMove.OnPotentialTargetMousedOver += ColorTilesMousedOver;

                placeToMove.OnPotentialTargetMousedOut += (t) => {
                    if (cachedPath != null)
                    {
                        MapManager.instance.UnColorTiles(cachedPath);
                    }
                    DestroyAOOPLines();
                };


                placeToMove.targetTileFilters.Add(ActionTargetTileParameter.OnlyMovable);


                actionTargetParameters.Add(placeToMove);
            }
Пример #3
0
 public override void FillNextParameter(ActionTargetTileParameter ap = null)
 {
     if (spaceWait)
     {
         UIManager.instance.OnKeyPressed += KeyGotPressed;
     }
     else
     {
         CallOnParamsFilled();
     }
 }
Пример #4
0
            //
            //		public virtual new bool CanBeUsedBy(Actor a) {
            //			//AttackTypeOption opt = ActionOptions [0] as AttackTypeOption;
            //			foreach(ActionOption opt in ActionOptions) {
            //
            //				foreach(AttackTypeChoice c in opt.GetChoices(a.CharSheet, this)) {
            //					opt.chosenChoice = c;
            //					foreach (ActionTargetTile potentialParam in GetActionTargetTileParameters()) {
            //						if (potentialParam.CanBeFilled ())
            //							return true;
            //					}
            //				}
            //			}
            //
            //			return false;
            ////
            ////			List<Actor> list;
            ////				list = a.AllMainHandAttackOptions ();
            ////
            ////			if (list.Count > 0)
            ////				return true;
            ////			return false;
            //		}



            public Actor TargetActor()
            {
                if (cachedTargetActor != null)
                {
                    return(cachedTargetActor);
                }
                ActionTargetTileParameter param = actionTargetParameters [0];

                //you can assume that the tile has an occupant....
                return(param.chosenTile.FirstOccupant.ActorComponent);
            }
Пример #5
0
            private List <ATTile> HasFriendlyAndFriendlyHasInventoryAndInteraction(List <ATTile> tiles, Actor actr)
            {
                List <ATTile> ret = ActionTargetTileParameter.HasFriendlyCharacter(tiles, actr)
                                    .Where((tile) => {
                    bool actingPossible = (!tile.FirstOccupant.ActorComponent.UsedInteraction() ||
                                           !tile.FirstOccupant.ActorComponent.UsedAction());
                    bool inventoryFree = !tile.FirstOccupant.ActorComponent.CharSheet.inventory.NoRoomLeft;
                    return(actingPossible && inventoryFree);
                }).ToList();

                return(ret);
            }
Пример #6
0
            public virtual void CancelUiListen()
            {
                if (prev != null)
                {
                    //prev.Reset ();
                    prev.OnTargetTileChosen -= FillNextParameter;
                    prev = null;
                }

                foreach (ActionTargetTileParameter ap in actionTargetParameters)
                {
                    ap.StopListen();
                }
            }
Пример #7
0
            void InitSingleEnemyTargetParam()
            {
                ActionTargetTileParameter targetParam = new ActionTargetTileParameter(this, Spell.rangeInSquares);

                targetParam.OnListen += (List <ATTile> potentialTargets) => {
                    //color red
                    MapManager.instance.ColorTiles(potentialTargets, new Color(1f, 0f, 0f, .3f));
                };


                targetParam.OnStopListen += (List <ATTile> potentialTargets) => {
                    MapManager.instance.UnColorTiles(potentialTargets);
                };

                targetParam.Prompt = "Choose an Enemy";
                targetParam.targetTileFilters.Add(ActionTargetTileParameter.HaveEnemies);
                actionTargetParameters.Add(targetParam);
            }
Пример #8
0
            public GiveItem(Actor actor = null) : base(actor)
            {
                this.ActionOptions.Add(new ItemsOnPersonOption());

                ActionTargetTileParameter param = new ActionTargetTileParameter(this, GIVE_DISTANCE);

                param.targetTileFilters.Add(HasFriendlyAndFriendlyHasInventoryAndInteraction);
                param.OnListen += (List <ATTile> potentialTargets) => {
                    //color green
                    MapManager.instance.ColorTiles(potentialTargets, new Color(0f, 1f, 0f, .3f));
                };


                param.OnStopListen += (List <ATTile> potentialTargets) => {
                    MapManager.instance.UnColorTiles(potentialTargets);
                };

                this.actionTargetParameters.Add(param);
            }
Пример #9
0
            //TODO: bring this to other side: casting!
            public override void LateSetTargetParameters()
            {
                AttackTypeOption          typeOpt = ActionOptions [0] as AttackTypeOption;
                AttackTypeChoice          choice  = typeOpt.chosenChoice as AttackTypeChoice;
                ActionTargetTileParameter targetParam;

                if (choice == null)
                {
                    Debug.LogError("isssues bub. can't get target tile params without knowing attack type");
                }

                if (choice.IsRanged())
                {
                    targetParam = new ActionTargetTileParameter(this, choice.weapon.MaxRng);
                }
                else
                {
                    //				Debug.Log ("IS NOR RANGED");
                    targetParam = new ActionTargetTileParameter(this);
                }


                targetParam.OnListen += (List <ATTile> potentialTargets) => {
                    //color red
                    MapManager.instance.ColorTiles(potentialTargets, new Color(1f, 0f, 0f, .3f));
                };


                targetParam.OnStopListen += (List <ATTile> potentialTargets) => {
                    MapManager.instance.UnColorTiles(potentialTargets);
                };

                targetParam.Prompt = "Choose an Enemy";

                cachedTargetActor = null;
                targetParam.OnTargetTileChosen += CacheTargetActor;
                targetParam.targetTileFilters.Add(ActionTargetTileParameter.HaveEnemies);
                actionTargetParameters = new List <ActionTargetTileParameter> {
                    targetParam
                };
            }
Пример #10
0
            public override void Perform()
            {
                CallOnBegan();

                Debug.LogError("AM I AN INTERACTION??? " + IsInteraction);

                ItemsOnPersonOption opt    = ActionOptions [0] as ItemsOnPersonOption;
                InventoryItemChoice choice = opt.chosenChoice as InventoryItemChoice;

                ActionTargetTileParameter param = actionTargetParameters [0];

                List <InventoryItem> items = actor.CharSheet.inventory.ListOfItems();
                InventoryItem        ch    = choice.item;

                if (items.Contains(ch))
                {
                    actor.CharSheet.inventory.RemoveItem(choice.item);
                }
                else if (actor.CharSheet.PaperDoll.slots.ContainsValue(choice.item as Equipment))
                {
                    actor.CharSheet.PaperDoll.Unequip(choice.item as Equipment, actor.CharSheet);
                }

                Actor targetTaker = param.chosenTile.FirstOccupant.ActorComponent;

                PickUp compoundAction = new PickUp(targetTaker);

                if (targetTaker.UsedInteraction())
                {
                    compoundAction.IsInteraction = false;
                }
                compoundAction.ActionOptions [0].chosenChoice = new InventoryItemChoice(choice.item) as IActionOptionChoice;

                compoundAction.Perform();
//			TileMovement tm = actor.GetComponent<TileMovement> ();
//			tm.occupying.onTheGround.Add (choice.item);

                CallOnFinished();
            }
        void A_OnWillFill(Action self, ActionTargetTileParameter ap)
        {
//			Debug.Log ("fillin to the vill: " + ap.Prompt);
            UIManager.instance.waitText.text = ap.Prompt;
        }
Пример #12
0
 private void CacheTargetActor(ActionTargetTileParameter param)
 {
     param.OnTargetTileChosen -= CacheTargetActor;
     cachedTargetActor         = param.chosenTile.FirstOccupant.ActorComponent;
 }