public void Init(Targets targets = Targets.enemy) { bsMachine.TransitionToState(BattleStateMachine.MenuState.Targetting); _showHighlights = true; HighlightAll = HighlightEnemies = HighlightTeam = false; switch (targets) { case Targets.enemy: for (int i = 0; i < unitSlots.Length; i++) { if (unitSlots[i].IsEnemy && unitSlots[i].GetUnit() != null && !unitSlots[i].GetUnit().GetComponent <BattleUnitEnemy>().IsDead) { currentHighlight = unitSlots[i]; break; } } break; case Targets.teammate: for (int i = 0; i < unitSlots.Length; i++) { if (!unitSlots[i].IsEnemy && !unitSlots[i].GetUnit().GetComponent <BattleUnitPlayer>().IsDead) { currentHighlight = unitSlots[i]; break; } } break; case Targets.allEnemies: HighlightEnemies = true; for (int i = 0; i < unitSlots.Length; i++) { if (unitSlots[i].IsEnemy) { currentHighlight = unitSlots[i]; break; } } break; case Targets.all: HighlightAll = true; currentHighlight = null; break; case Targets.team: HighlightTeam = true; currentHighlight = null; break; default: Debug.Log("invalid choice"); break; } }
public void OnMouseUp() { if (!IsSelectable) { return; } UnitSlot slotTarget = UIManager.Instance.SlotTarget; if (slotTarget != null) { if (slotTarget.Unit != null) { CommandManager.Instance.Attack(this, slotTarget.Unit); Deselect(); } else { if (CommandManager.Instance.IsValidMove(this, slotTarget)) { CommandManager.Instance.Move(this, slotTarget); } Deselect(); } } else { Deselect(); } _collider.enabled = true; }
void Awake() { caster = (GraphicRaycaster)Utility.GetFirstComponentInParents(gameObject, typeof(GraphicRaycaster)); slot = (UnitSlot)Utility.GetFirstComponentInParents(gameObject, typeof(UnitSlot)); slot.draggableImage = this; originalColor = background.color; }
public void SaveHiredSoldiers() { List <BaseSoldier> soldiers = new List <BaseSoldier>(); for (int i = 0; i < UnitSlotsRO.Length; i++) { if (UnitSlotsRO[i] != null) { BaseSoldierData soldierData = UnitSlotsRO[i].UnitData; if (soldierData != null) { BaseSoldier soldier = new BaseSoldier(soldierData, Global.Instance.Player.City.GetSoldierUpgradesInfo(soldierData.Key).Level); soldier.TemplatePlace = UnitSlotsRO[i].Place; soldiers.Add(soldier); } } } Global.Instance.CurrentMission.SelectedSoldiers = new ArrayRO <BaseSoldier>(soldiers.ToArray()); UnitSlot[] slotTemplate = new UnitSlot[soldiers.Count]; for (int i = 0; i < slotTemplate.Count(); i++) { slotTemplate[i] = new UnitSlot(soldiers[i].TemplatePlace, soldiers[i].Data.Key); } Global.Instance.Player.Heroes.Current.Data.SlotTemplate = new ArrayRO <UnitSlot>(slotTemplate); }
public static void SetDestinationUnitSlot(UnitSlot destinationUnitSlot) { switch (activeGameContextID) { case GameContextID.None: Debug.LogWarning("None: Return"); return; case GameContextID.Map: Debug.LogWarning("Map: Return"); return; case GameContextID.Battle: Debug.Log("Set DestinationUnitSlot for Battle context"); BattleContext.DestinationUnitSlot = destinationUnitSlot; return; case GameContextID.EditPartyScreen: Debug.Log("Set DestinationUnitSlot for EditPartyScreen context"); EditPartyScreenContext.DestinationUnitSlot = destinationUnitSlot; return; case GameContextID.EquipmentScreen: Debug.LogWarning("EquipmentScreen: Return"); return; default: Debug.LogError("Unknown game context"); return; } }
private void Update() { if (_showHighlights) { //If all need to be targetted if (HighlightAll || HighlightEnemies) { //Do something? } else { if (currentHighlight != null && _inputManager.GetAxisDown(InputManager.Axis.Horizontal, out _inputRight)) { if (_inputRight) { currentHighlight = GetRightUnitSlot(currentHighlight); } else { currentHighlight = GetLeftUnitSlot(currentHighlight); } } } } else { currentHighlight = null; } }
public bool IsValidPlay(GameEntity entity, UnitSlot slot) { if (activeDialog != null && activeDialog is ICommandFilter) { return(((ICommandFilter)activeDialog).IsValidPlay(entity, slot)); } return(!tutorialMode); }
private void Start() { originalSize = transform.localScale; originalPosition = transform.localPosition; randomStart = (isRandomStart) ? Random.Range(0f, 0.8f) : 0; thisSlot = GetComponentInParent <UnitSlot>(); meshRenderer = GetComponent <MeshRenderer>(); }
public bool IsValidDiscard(GameEntity entity, UnitSlot slot) { if (!IsValidPlay(entity, slot)) { return(false); } return(validPlays.IsDiscardTarget(entity, slot)); }
void OnDismissNoConfirmation() { Debug.Log("No"); // activate hire unit pnl button SetHireUnitPnlButtonActive(true); // clear cached unit slot reference unitSlotToDismissCache = null; }
void Start() { card = GameManager.Instance.GetEntity(data.cardId) as CardEntity; if (data.x >= 0) { UnitSlot slot = GameManager.Instance.gameBoard.GetSlot(data.x, data.y); } }
public static Payload UnlockSlot(UnitSlot slot) { return(new Payload { RequestClass = ClassName, RequestMethod = "unlockSlot", RequestData = new JArray(slot.Parent.ID, slot.Order, 0) }); }
private void SetSlots() { for (int i = 0; i < TurnManager.instance.allyUnits.Count; i++) { selectedSlot = Instantiate(unitSlot, transform); SlotPosition(); selectedSlot.FillSlot(TurnManager.instance.allyUnits[i]); } }
public SummonUnitCommand(int id, EntityView card, UnitSlot slot) : base(id) { if(card.id <=0) { throw new System.Exception("Card was missing id"); } cardEntityId = card.id; x = slot.x; y = slot.y; }
void OnDismissYesConfirmation() { Debug.Log("Yes"); // activate hire unit pnl button SetHireUnitPnlButtonActive(true); // Ask city to dismiss unit DimissUnit(unitSlotToDismissCache); // clear cached unit slot reference unitSlotToDismissCache = null; }
// Use this for initialization void Start() { targetSlot = GameManager.Instance.gameBoard.GetSlot(command.x, command.y); crosshairs.SetColor(crossHairColor, 0.75f); transform.position = new Vector3(0, 100, 0); transform.localScale = new Vector3(15, 15, 15); transform.eulerAngles = new Vector3(15, 90, 0); lerperTransform = GetComponent <LerpTransform>(); lerperTransform.SetTransform(targetSlot.transform, 1f); }
// Use this for initialization void Start () { targetSlot = GameManager.Instance.gameBoard.GetSlot(command.x, command.y); crosshairs.SetColor(crossHairColor, 0.75f); transform.position = new Vector3(0, 100, 0); transform.localScale = new Vector3(15, 15, 15); transform.eulerAngles = new Vector3(15, 90, 0); lerperTransform = GetComponent<LerpTransform>(); lerperTransform.SetTransform(targetSlot.transform, 1f); }
public float getUnitRunePoint(UnitSlot slot) { float returnValue = 0; for (int i = unitRunePointChecker.Length - 1; i >= 0; --i) { returnValue += unitRunePointChecker[i].getUnitRunePoint(this, slot); } return(returnValue); }
public SummonUnitCommand(int id, EntityView card, UnitSlot slot) : base(id) { if (card.id <= 0) { throw new System.Exception("Card was missing id"); } cardEntityId = card.id; x = slot.x; y = slot.y; }
private UnitSlot CreateSlot(Vector3 position, GameObject prefab, Transform container) { GameObject go = GameObject.Instantiate(prefab); UnitSlot slot = go.GetComponentInChildren <UnitSlot>(); go.transform.SetParent(container); go.transform.localRotation = Quaternion.identity; go.transform.localPosition = new Vector3(position.x, 0, position.z); return(slot); }
public void update() { if (GameManager.me.characterManager.playerMonsterRightLine >= waitLine) { Monster summonMon = GameManager.me.mapManager.addMonsterToStage(null, null, false, null, _waitUnitData.id, _v, _waitUnitData); _v.y = 0.5f; GameManager.info.effectData[UnitSlot.getSummonEffectByRare(_waitUnitData.rare)].getEffect(-1000, _v, null, null, summonMon.summonEffectSize); _waitUnitData = null; GameManager.me.characterManager.removeAndSetWaitMonster(this); } }
override public bool IsValidPlay(GameEntity entity, UnitSlot slot) { if (entity.PrototypeId == prototypeId) { if (slot == targetSlot) { return(true); } } return(false); }
void Start() { this.unit = GameManager.Instance.GetEntity(data.entityId).GetComponent <UnitEntity>(); this.unit.AwaitingAck = false; this.unit.Deselect(); UnitSlot slot = GameManager.Instance.gameBoard.GetSlot(data.x, data.y); slot.Unit = unit; unit.lerper.SetPosition(slot.transform.position, moveTime); Debug.Log(unit + " is moving to " + slot.x + "," + slot.y); }
override public bool IsValidPlay(GameEntity entity, UnitSlot slot) { if(entity.PrototypeId == prototypeId) { if(slot == targetslot) { return true; } } return false; }
public void AddUnitSlotToTransfer(UnitSlot slot, out bool alreadyInTransfer) { if (!unitTransfer.Contains(slot.unit)) { unitTransfer.Add(slot.unit); alreadyInTransfer = false; } else { Debug.Log("Already in transfer"); alreadyInTransfer = true; } }
public bool IsValidMove(UnitEntity unit, UnitSlot slot) { if (unit == null) { return(false); } if (!IsValidPlay(unit, slot)) { return(false); } return(true); }
public bool Move(UnitEntity unit, UnitSlot destination) { if (!IsValidMove(unit, destination)) { Debug.Log(unit + " cannot move to " + destination); return(false); } EntityView moveUnit = unit.EntityView; MoveCommand command = new MoveCommand(NextId, moveUnit, destination.x, destination.y); SendCommand(command); return(true); }
/// <summary> /// Play a card on an empty slot (summon a unit) /// </summary> /// <param name="cardData"></param> /// <param name="slot"></param> public bool SummonUnit(GameEntity card, UnitSlot slot) { if (!IsValidPlay(card, slot)) { Debug.LogWarning(card + " cannot be played on " + slot); return(false); } EntityView cardData = card.EntityView; SummonUnitCommand command = new SummonUnitCommand(NextId, cardData, slot); SendCommand(command); return(true); }
public bool PlayPower(CardEntity card, UnitSlot slot) { if (!IsValidPlay(card, slot)) { Debug.Log("Invalid play"); return(false); } EntityView cardView = card.EntityView; PlayPowerCommand command = new PlayPowerCommand(NextId, cardView, slot); SendCommand(command); return(true); }
public bool Discard(CardEntity card, UnitSlot slot) { if (!IsValidDiscard(card, slot)) { Debug.Log("Invalid discard"); return(false); } EntityView cardView = card.EntityView; DiscardCommand command = new DiscardCommand(NextId, cardView, slot); SendCommand(command); return(true); }
public void DismissGenericUnit(UnitSlot unitSlot) { // get PartyUnit UI PartyUnitUI unitUI = unitSlot.GetComponentInChildren <PartyUnitUI>(); // get PartyUnit PartyUnit partyUnit = unitUI.LPartyUnit; // Get Unit size, because unit is going to be destroyed UnitSize unitSize = partyUnit.UnitSize; // Get Party Unit HeroParty //HeroParty heroParty = partyUnit.GetComponentInParent<HeroParty>(); // 1 get all required variables, before removing unit Transform unitCell = unitSlot.transform.parent; PartyPanel partyPanel = GetUnitsParentPartyPanel(unitCell); // 2 and put it to recycle bin, because otherwise PartyPanel.GetNumberOfPresentUnits() will return wrong number of units, because object is actually destroyed after Update() // unitUI.transform.SetParent(transform.root.GetComponentInChildren<RecycleBin>().transform); // 3 destory unit canvas, where it is linked to // Destroy(unitUI.gameObject); // 4 and put it to recycle bin, because otherwise city.GetNumberOfPresentUnits() will return wrong number of units, because object is actually destroyed after Update() // partyUnit.transform.SetParent(transform.root.GetComponentInChildren<RecycleBin>().transform); // 5 and destory party unit itself // Destroy(partyUnit.gameObject); RecycleBin.Recycle(unitUI.gameObject); RecycleBin.Recycle(partyUnit.gameObject); // Update party panel // act based on the unit size if (unitSize == UnitSize.Single) { partyPanel.OnChange(PartyPanel.ChangeType.DismissSingleUnit, unitCell); } else { partyPanel.OnChange(PartyPanel.ChangeType.DismissDoubleUnit, unitCell); } // if parent Party panel is in Garnizon state, then update focus panel if (PartyMode.Garnizon == partyPanel.PartyMode) { // Instruct focus panel linked to a city to update information // act based on the unit size if (unitSize == UnitSize.Single) { GetComponentInParent <UIManager>().GetFocusPanelByCity(LCity).OnChange(FocusPanel.ChangeType.DismissSingleUnit); } else { GetComponentInParent <UIManager>().GetFocusPanelByCity(LCity).OnChange(FocusPanel.ChangeType.DismissDoubleUnit); } // Activate hire unit buttons again SetHireUnitPnlButtonActive(true); } }
public override bool IsValidPlay(GameEntity entity, UnitSlot slot) { if (slot != null && entity != null && entity.EntityView.InPlay) { if (entity.EntityView.column == fromX && entity.EntityView.row == fromY) { if (slot.x == toX && slot.y == toY) { return(true); } } } return(false); }
public override bool IsValidPlay(GameEntity entity, UnitSlot slot) { if (slot != null && entity != null && entity.EntityView.InPlay) { if (entity.EntityView.column == fromX && entity.EntityView.row == fromY) { if(slot.x == toX && slot.y == toY) { return true; } } } return false; }
//internal UnitOfMeasure( LocaleData locale, string name ) { // WellKnownUnit unit; // if ( XUtil.TryParseUnit( name, out unit ) ) { // Unit = unit; // Name = unit.ToCode(); // } else { // Name = name; // } //} //internal UnitSlot Load( FormatSize size, JObject root ) { // int idx = GetIndex( size ); // if ( idx < 0 ) { // return null; // } // UnitSlot slot = new UnitSlot( this, size ); // _sizes[ idx ] = slot; // slot.Load( root ); // return slot; //} internal UnitSlot Load(FormatLength size, LdmlTypeUnitNode root) { int idx = GetIndex(size); if (idx < 0) { return(null); } UnitSlot slot = new UnitSlot(this, size); _sizes[idx] = slot; slot.Load(root); return(slot); }
public PlayPowerCommand(int id, EntityView card, UnitSlot slot) : base(id) { this.cardEntityId = card.id; if(slot != null) { this.x = slot.x; this.y = slot.y; } else { this.x = -1; this.y = -1; } }
public override bool IsValidPlay(GameEntity entity, UnitSlot slot) { if(entity.EntityView.InPlay) { if(targetPrototypeId == "") { return true; } if(slot != null && slot.unit != null && slot.unit.PrototypeId == targetPrototypeId) { return true; } } return false; }
void Start() { elapsed = 0; card = GameManager.Instance.GetEntity(data.cardView.id) as CardEntity; GameManager.Instance.opponentHand.RemoveCard(card); if(card == null) { Debug.LogError("Card not found"); enabled = false; } card.EntityView = data.cardView; card.lerpTransform.SetTransform(GameManager.Instance.gameBoard.cardReveal, 0.5f); if (data.cardView.column >= 0) { slot = GameManager.Instance.gameBoard.GetSlot(data.cardView.column, data.cardView.row); } }
public bool IsDiscardTarget(GameEntity entity, UnitSlot slot) { if (slot == null) return false; if(validDiscards.ContainsKey(entity.EntityId)) { foreach(EntityCoords coord in validDiscards[entity.EntityId]) { if(coord.x == slot.x && coord.y == slot.y) { return true; } } } return false; }
override protected void Activate() { base.Activate(); targetSlot = GameManager.Instance.gameBoard.GetSlot(fromX, fromY); pointerTarget = targetSlot.gameObject; }
public void SaveHiredSoldiers() { List<BaseSoldier> soldiers = new List<BaseSoldier>(); for (int i = 0; i < UnitSlotsRO.Length; i++) { if (UnitSlotsRO[i] != null) { BaseSoldierData soldierData = UnitSlotsRO[i].UnitData; if (soldierData != null) { BaseSoldier soldier = new BaseSoldier(soldierData, Global.Instance.Player.City.GetSoldierUpgradesInfo(soldierData.Key).Level); soldier.TemplatePlace = UnitSlotsRO[i].Place; soldiers.Add(soldier); } } } Global.Instance.CurrentMission.SelectedSoldiers = new ArrayRO<BaseSoldier>(soldiers.ToArray()); UnitSlot[] slotTemplate = new UnitSlot[soldiers.Count]; for (int i = 0; i < slotTemplate.Count(); i++) slotTemplate[i] = new UnitSlot(soldiers[i].TemplatePlace, soldiers[i].Data.Key); Global.Instance.Player.Heroes.Current.Data.SlotTemplate = new ArrayRO<UnitSlot>(slotTemplate); }
/// <summary> /// Can this entity be played on the supplied slot? If the slot is null, /// can this entity be played without a target? /// </summary> /// <param name="entity"></param> /// <param name="slot"></param> /// <returns></returns> public bool IsValidPlay(GameEntity entity, UnitSlot slot) { if (validPlays == null) precalcValidPlays(); if (slot == null) { return validNoTargetPlays.Contains(entity.EntityId); } if (validPlays.ContainsKey(entity.EntityId)) { return validPlays[entity.EntityId].Contains(slot); } return false; }
public bool IsValidPlay(GameEntity entity, UnitSlot slot) { if (activeDialog != null && activeDialog is ICommandFilter) { return ((ICommandFilter)activeDialog).IsValidPlay(entity, slot); } return !tutorialMode; }
protected virtual void Start () { targetSlot = GameManager.Instance.gameBoard.GetSlot(summoned.column, summoned.row); particleSystems = GetComponentsInChildren<ParticleSystem>(); transform.position = targetSlot.transform.position; }
override protected void Activate() { targetSlot = GameManager.Instance.gameBoard.GetSlot(col, row); pointerTarget = targetSlot.gameObject; }
public bool IsValidSlotTarget(UnitSlot slot) { return CommandManager.Instance.IsValidPlay(this, slot); }
public virtual bool IsValidPlay(GameEntity entity, UnitSlot slot) { return allowCommands; }