コード例 #1
0
    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;
        }
    }
コード例 #2
0
    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;
    }
コード例 #3
0
 void Awake()
 {
     caster = (GraphicRaycaster)Utility.GetFirstComponentInParents(gameObject, typeof(GraphicRaycaster));
     slot   = (UnitSlot)Utility.GetFirstComponentInParents(gameObject, typeof(UnitSlot));
     slot.draggableImage = this;
     originalColor       = background.color;
 }
コード例 #4
0
    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);
    }
コード例 #5
0
    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;
        }
    }
コード例 #6
0
 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;
     }
 }
コード例 #7
0
 public bool IsValidPlay(GameEntity entity, UnitSlot slot)
 {
     if (activeDialog != null && activeDialog is ICommandFilter)
     {
         return(((ICommandFilter)activeDialog).IsValidPlay(entity, slot));
     }
     return(!tutorialMode);
 }
コード例 #8
0
 private void Start()
 {
     originalSize     = transform.localScale;
     originalPosition = transform.localPosition;
     randomStart      = (isRandomStart) ? Random.Range(0f, 0.8f) : 0;
     thisSlot         = GetComponentInParent <UnitSlot>();
     meshRenderer     = GetComponent <MeshRenderer>();
 }
コード例 #9
0
ファイル: CommandManager.cs プロジェクト: tmcfar/galacdecks
 public bool IsValidDiscard(GameEntity entity, UnitSlot slot)
 {
     if (!IsValidPlay(entity, slot))
     {
         return(false);
     }
     return(validPlays.IsDiscardTarget(entity, slot));
 }
コード例 #10
0
 void OnDismissNoConfirmation()
 {
     Debug.Log("No");
     // activate hire unit pnl button
     SetHireUnitPnlButtonActive(true);
     // clear cached unit slot reference
     unitSlotToDismissCache = null;
 }
コード例 #11
0
 void Start()
 {
     card = GameManager.Instance.GetEntity(data.cardId) as CardEntity;
     if (data.x >= 0)
     {
         UnitSlot slot = GameManager.Instance.gameBoard.GetSlot(data.x, data.y);
     }
 }
コード例 #12
0
 public static Payload UnlockSlot(UnitSlot slot)
 {
     return(new Payload
     {
         RequestClass = ClassName,
         RequestMethod = "unlockSlot",
         RequestData = new JArray(slot.Parent.ID, slot.Order, 0)
     });
 }
コード例 #13
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]);
     }
 }
コード例 #14
0
ファイル: SummonUnitCommand.cs プロジェクト: wx3/galacdecks
	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;
    }
コード例 #15
0
 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;
 }
コード例 #16
0
 // 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);
 }
コード例 #17
0
    // 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);
        
	}
コード例 #18
0
    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);
    }
コード例 #19
0
 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;
 }
コード例 #20
0
    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);
    }
コード例 #21
0
 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);
     }
 }
コード例 #22
0
 override public bool IsValidPlay(GameEntity entity, UnitSlot slot)
 {
     if (entity.PrototypeId == prototypeId)
     {
         if (slot == targetSlot)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #23
0
    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);
    }
コード例 #24
0
ファイル: PlayUnit.cs プロジェクト: wx3/galacdecks
 override public bool IsValidPlay(GameEntity entity, UnitSlot slot)
 {
     if(entity.PrototypeId == prototypeId)
     {
         if(slot == targetslot)
         {
             return true;
         }
     }
     return false;
 }
コード例 #25
0
 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;
     }
 }
コード例 #26
0
ファイル: CommandManager.cs プロジェクト: tmcfar/galacdecks
 public bool IsValidMove(UnitEntity unit, UnitSlot slot)
 {
     if (unit == null)
     {
         return(false);
     }
     if (!IsValidPlay(unit, slot))
     {
         return(false);
     }
     return(true);
 }
コード例 #27
0
ファイル: CommandManager.cs プロジェクト: tmcfar/galacdecks
    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);
    }
コード例 #28
0
ファイル: CommandManager.cs プロジェクト: tmcfar/galacdecks
    /// <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);
    }
コード例 #29
0
ファイル: CommandManager.cs プロジェクト: tmcfar/galacdecks
    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);
    }
コード例 #30
0
ファイル: CommandManager.cs プロジェクト: tmcfar/galacdecks
    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);
    }
コード例 #31
0
    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);
        }
    }
コード例 #32
0
ファイル: Move.cs プロジェクト: tmcfar/galacdecks
 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);
 }
コード例 #33
0
ファイル: Move.cs プロジェクト: wx3/galacdecks
 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;
 }
コード例 #34
0
        //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);
        }
コード例 #35
0
ファイル: PlayPowerCommand.cs プロジェクト: wx3/galacdecks
 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;
     }
     
 }
コード例 #36
0
ファイル: Attack.cs プロジェクト: wx3/galacdecks
 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;
 }
コード例 #37
0
    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);
        }
    }
コード例 #38
0
ファイル: ValidPlays.cs プロジェクト: wx3/galacdecks
 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;
 }
コード例 #39
0
ファイル: Move.cs プロジェクト: wx3/galacdecks
 override protected void Activate()
 {
     base.Activate();
     targetSlot = GameManager.Instance.gameBoard.GetSlot(fromX, fromY);
     pointerTarget = targetSlot.gameObject;
 }
コード例 #40
0
    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);
    }
コード例 #41
0
ファイル: ValidPlays.cs プロジェクト: wx3/galacdecks
 /// <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;
 }
コード例 #42
0
ファイル: ScriptedDialogBox.cs プロジェクト: wx3/galacdecks
 public bool IsValidPlay(GameEntity entity, UnitSlot slot)
 {
     if (activeDialog != null && activeDialog is ICommandFilter)
     {
         return ((ICommandFilter)activeDialog).IsValidPlay(entity, slot);
     }
     return !tutorialMode;
 }
コード例 #43
0
ファイル: SummonUnitBehaviour.cs プロジェクト: wx3/galacdecks
 protected virtual void Start () {
     targetSlot = GameManager.Instance.gameBoard.GetSlot(summoned.column, summoned.row);
     particleSystems = GetComponentsInChildren<ParticleSystem>();
     transform.position = targetSlot.transform.position;
 }
コード例 #44
0
ファイル: PlayCard.cs プロジェクト: wx3/galacdecks
 override protected void Activate()
 {
     targetSlot = GameManager.Instance.gameBoard.GetSlot(col, row);
     pointerTarget = targetSlot.gameObject;
 }
コード例 #45
0
ファイル: GameEntity.cs プロジェクト: wx3/galacdecks
 public bool IsValidSlotTarget(UnitSlot slot)
 {
     return CommandManager.Instance.IsValidPlay(this, slot);
 }
コード例 #46
0
ファイル: TutorialScript.cs プロジェクト: wx3/galacdecks
 public virtual bool IsValidPlay(GameEntity entity, UnitSlot slot)
 {
     return allowCommands;
 }