Exemplo n.º 1
0
 public void Execute(IRuntimeJewel data)
 {
     if (data.Data.JewelID == JewelID.wrath)
     {
         collider.size = new Vector3(2.5f, 2.5f, 0);
     }
 }
Exemplo n.º 2
0
 public void Execute(IRuntimeJewel data)
 {
     if (data.Data.JewelID == JewelID.wrath)
     {
         transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
     }
 }
Exemplo n.º 3
0
        private IEnumerator PositionJewelFromQueue(IRuntimeJewel jq, IRuntimeJewel jq2)
        {
            Vector2 BoardTo1   = BoardPos.OffsetJewelByPosition(jq.Pos);
            Vector2 BoardFrom1 = BoardPos.OffsetJewelByPosition(jq.LastPos);

            Vector3 to1   = BoardPos.GetNextJewelPosition(BoardTo1, utils.DeckPosition.position);
            Vector3 from1 = BoardPos.GetNextJewelPosition(BoardFrom1, utils.DeckPosition.position);

            GameEvents.Instance.Notify <IPositionJewel>(i => i.OnJewelPosition(jq, from1, to1));

            Vector2 BoardTo2   = BoardPos.OffsetJewelByPosition(jq2.Pos);
            Vector2 BoardFrom2 = BoardPos.OffsetJewelByPosition(jq2.LastPos);

            Vector3 to2   = BoardPos.GetNextJewelPosition(BoardTo2, utils.DeckPosition.position);
            Vector3 from2 = BoardPos.GetNextJewelPosition(BoardFrom2, utils.DeckPosition.position);

            GameEvents.Instance.Notify <IPositionJewel>(i => i.OnJewelPosition(jq2, from2, to2));

            yield return(new WaitForSeconds(utils.JEWELPOSITIONDELAY));

            jq.DoUnselect();
            jq2.DoUnselect();

            yield return(new WaitForSeconds(utils.JEWELPOSITIONUNSELECTDELAY));

            OnDonePosition();
        }
Exemplo n.º 4
0
        public IEnumerator ExecuteAiAbility(PlayerSeat seat)
        {
            List <IRuntimeAbility> abilityBuff = AiModule.GetBestAbility(seat);

            if (abilityBuff.Count > 0)
            {
                GameObject GO = GameObject.FindGameObjectsWithTag("UiPanel").Where((go) => go.GetComponent <IUiPlayerHUD>().Seat == seat).ToList()[0];
                // Check for nav
                if (GO.GetComponent <IUiPlayerHUD>().UINavButtons.Current != NavID.Attack)
                {
                    // click on the ability
                    GameEvents.Instance.Notify <IPlayerNav>(i => i.OnPlayerNav(seat, NavID.Attack));
                    yield return(new WaitForSeconds(1f));
                }

                // click on the ability
                GameEvents.Instance.Notify <ISelectAtkActionButton>(i => i.OnSelectAtkActionButton(seat, abilityBuff[0].Ability.AbilityID));
                //Debug.Log("AI clicked on ability");

                yield return(new WaitForSeconds(1f));

                while (!BoardController.Instance.CanClickJewel())
                {
                }

                IRuntimeJewel jwl = AiModule.GetAbilityJewels(seat, abilityBuff[0])[0];
                GameEvents.Instance.Notify <ISelectJewel>(i => i.OnSelect(jwl));
                //Debug.Log("AI clicked on jewel");
                yield return(new WaitForSeconds(2f));
            }
            //while (!BoardController.Instance.CanManipulate()) { }
            //Debug.Log("AI ready to perform next action!");
            Fsm.Handler.MonoBehaviour.StartCoroutine(ExecuteAiTurn(seat));
        }
Exemplo n.º 5
0
 public void OnPostTransformJewel(IRuntimeJewel jewel)
 {
     if (UIRuntimeData.RuntimeData.JewelID == jewel.JewelID)
     {
         UIRuntimeData.OnSetData?.Invoke(jewel);
     }
 }
Exemplo n.º 6
0
        public static int WillCauseMatchCount(IRuntimeJewel[,] jewels, IRuntimeJewel swap1, IRuntimeJewel swap2, List <JewelID> prefJewels = null)
        {
            jewels[(int)swap1.Pos.x, (int)swap1.Pos.y] = swap2;
            jewels[(int)swap2.Pos.x, (int)swap2.Pos.y] = swap1;
            int MatchCount = 0;
            List <IRuntimeJewel> foundMatches = FindMatchesUtil.FindMatches(jewels);

            if (prefJewels != null)
            {
                List <JewelID> matchesPref = new List <JewelID>();
                foreach (IRuntimeJewel jwl in foundMatches)
                {
                    if (prefJewels.Contains(jwl.Data.JewelID) && !matchesPref.Contains(jwl.Data.JewelID))
                    {
                        matchesPref.Add(jwl.Data.JewelID);
                    }
                }
                MatchCount = foundMatches.Count + matchesPref.Count;
            }
            else
            {
                MatchCount = foundMatches.Count;
            }
            jewels[(int)swap1.Pos.x, (int)swap1.Pos.y] = swap1;
            jewels[(int)swap2.Pos.x, (int)swap2.Pos.y] = swap2;
            return(MatchCount);
        }
Exemplo n.º 7
0
 public void ExecuteDestroy(IRuntimeJewel jewelData)
 {
     if (jewelData == jewel)
     {
         Object.Destroy(parent.gameObject);
     }
 }
Exemplo n.º 8
0
 public void Execute(IRuntimeJewel jewelData)
 {
     if (SprRend != null && jewelData != null)
     {
         SprRend.sprite = jewelData.Data.Artwork;
     }
 }
Exemplo n.º 9
0
 private void OnRemove(IRuntimeJewel jewel)
 {
     // The jewel has to be removed from the data here so that the cascade works properly
     //board.GetBoardData().SetJewel(null, jewel.Pos);
     // Notify UI that the jewel needs to be removed
     GameEvents.Instance.Notify <IRemoveJewel>(i => i.OnRemoveJewel(jewel));
 }
Exemplo n.º 10
0
 public void StartReposition(IRuntimeJewel jewel)
 {
     JewelsToFall.Enqueue(jewel);
     if (JewelsFalling == null)
     {
         JewelsFalling = utils.MBehaviour.StartCoroutine(CascadeJewelFromQueue());
     }
 }
Exemplo n.º 11
0
        public override bool Execute(IRuntimeJewel TriggerJewel)
        {
            PlayerSeat       pSeat = EffectPlayer == PlayerEffectSeat.Active ? GameData.Instance.RuntimeGame.TurnLogic.CurrentPlayer.Seat : GameData.Instance.RuntimeGame.TurnLogic.NextPlayer.Seat;
            IRuntimeMoheData mohe  = GameController.Instance.GetPlayerController(pSeat).Player.Roster.CurrentMohe();

            GameEvents.Instance.Notify <IMoheHeal>(i => i.OnMoheHeal(mohe.InstanceID, (int)Random.Range(MinAmt, MaxAmt)));

            return(true);
        }
Exemplo n.º 12
0
 public void OnInvokeBoardActionCheck(IRuntimeJewel jewel)
 {
     if (board.OnInvokeActionEffect != null)
     {
         if (board.OnInvokeActionEffect.Invoke(jewel))
         {
             Notify();
         }
     }
 }
Exemplo n.º 13
0
        public static bool WillCauseMatch(IRuntimeJewel[,] jewels, IRuntimeJewel swap1, IRuntimeJewel swap2)
        {
            jewels[(int)swap1.Pos.x, (int)swap1.Pos.y] = swap2;
            jewels[(int)swap2.Pos.x, (int)swap2.Pos.y] = swap1;
            bool foundMatches = FindMatchesUtil.FindMatches(jewels).Count > 0;

            jewels[(int)swap1.Pos.x, (int)swap1.Pos.y] = swap1;
            jewels[(int)swap2.Pos.x, (int)swap2.Pos.y] = swap2;
            return(foundMatches);
        }
Exemplo n.º 14
0
 public IRuntimeJewel[,] GetMap()
 {
     IRuntimeJewel[,] jewels = new IRuntimeJewel[jewelMap.GetLength(0), jewelMap.GetLength(1)];
     for (int x = 0; x < jewelMap.GetLength(0); x++)
     {
         for (int y = 0; y < jewelMap.GetLength(1); y++)
         {
             jewels[x, y] = jewelMap[x, y];
         }
     }
     return(jewels);
 }
Exemplo n.º 15
0
 public void OnTransformJewel(IRuntimeJewel jewel, JewelID transformType)
 {
     //Debug.Log("OnTransformJewel");
     //Debug.Log(UIRuntimeData);
     //Debug.Log(jewel);
     if (UIRuntimeData.RuntimeData != null && UIRuntimeData.RuntimeData.JewelID == jewel.JewelID)
     {
         JewelData     data = JewelDatabase.Instance.Get(transformType);
         IRuntimeJewel jwl  = UIRuntimeData.RuntimeData;
         jwl.TransformJewel(data);
         UIRuntimeData.OnSetData?.Invoke(jwl);
     }
 }
Exemplo n.º 16
0
 public void OnRemoveJewel(IRuntimeJewel jewel)
 {
     if (GameData.Instance.RuntimeGame.IsTurnInProgress && GameController.Instance.GetPlayerController(player.Seat).IsMyTurn)
     {
         ChargeAbility(jewel.Data.JewelID);
         if (jewel.Data.JewelID == JewelID.wrath)
         {
             string id = GameController.Instance.GetOpponentPlayersController(player.Seat)
                         .Player.Roster.CurrentMohe().InstanceID;
             GameEvents.Instance.Notify <IMoheTakeDamage>(i => i.OnMoheTakeDamage(id, 1));
         }
         Notify();
     }
 }
Exemplo n.º 17
0
 public void OnPostSelect(IRuntimeJewel jewel)
 {
     if (jewel != null && jewel.JewelID == Jewel.JewelID)
     {
         Debug.Log("OnSelect UiJewelOpacity");
         if (jewel.IsSelected)
         {
             renderer.color = new Color(.8f, .8f, .8f, 1);
         }
         else
         {
             renderer.color = new Color(1, 1, 1, 1);
         }
     }
 }
Exemplo n.º 18
0
        public override bool Execute(IRuntimeJewel TriggerJewel)
        {
            Debug.Log("Execute Destroy Effect!");

            // Destroy between MinAmt and MaxAmt of random Jewel
            // -1 values in MinAmt or MaxAmt will destroy all of type Jewel

            // Get gameboard
            IRuntimeJewel[,] board = GameData.Instance.RuntimeGame.GameBoard.GetBoardData().GetMap();

            // Find all jewels of type
            List <IRuntimeJewel> matching = new List <IRuntimeJewel>();

            int width  = board.GetLength(0);
            int height = board.GetLength(1);

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    if (board[x, y].Data.JewelID == Jewel || Jewel == JewelID.any)
                    {
                        matching.Add(board[x, y]);
                    }
                }
            }

            // Pick out the right jewels in range
            // -1 values in MinAmt or MaxAmt will destroy all of type Jewel
            if (MinAmt != -1 && MaxAmt != -1)
            {
                int amt = Random.Range(MinAmt, MaxAmt);
                ListExtensions.Shuffle(matching);
                matching = matching.Take(amt).ToList();
            }

            // Destroy jewels in list
            foreach (IRuntimeJewel jwl in matching)
            {
                //GameData.Instance.RuntimeGame.GameBoard.GetBoardData().SetJewel(null, jwl.Pos);
                GameEvents.Instance.Notify <IRemoveJewel>(i => i.OnRemoveJewel(jwl));
            }

            // Notify Evaluate
            //GameEvents.Instance.Notify<ICascadeBoard>(i => i.OnBoardCascadeCheck());

            return(true);
        }
Exemplo n.º 19
0
        public override void OnEnterState()
        {
            base.OnEnterState();

            //Debug.Log("CascadeBoardState");
            List <JewelData>     jewels      = JewelDatabase.Instance.GetFullList();
            List <IRuntimeJewel> readyJewels = new List <IRuntimeJewel>();

            IRuntimeJewel[,] jewelMap = board.GetBoardData().GetMap();
            int width  = jewelMap.GetLength(0);
            int height = jewelMap.GetLength(1);


            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    Vector2       pos     = new Vector2(x, y);
                    IRuntimeJewel jewel   = FindNextJewel(jewelMap, pos);
                    GameObject    UIJewel = jewel == null ? null : GameObject.Find(jewel.JewelID);
                    if (jewel == null || UIJewel == null)
                    {
                        jewel = new RuntimeJewel(jewels[Random.Range(0, jewels.Count)], pos, "Jewel_" + Count++);
                    }
                    else
                    {
                        // Rotate gem's position
                        jewel.RotatePos(pos);
                        // Remove old jewel position from buffer
                        jewelMap[(int)jewel.LastPos.x, (int)jewel.LastPos.y] = null;
                    }
                    // Place Jewel On Board
                    SetJewelData(jewel, pos);
                    // Update UI
                    readyJewels.Add(jewel);
                    // Update temp buffer
                    jewelMap[x, y] = jewel;
                }
            }

            //board.GetBoardData().PrettyJewelMap();

            // Update UI
            foreach (IRuntimeJewel jwl in readyJewels)
            {
                OnCascadeJewel(jwl);
            }
        }
Exemplo n.º 20
0
        public void OnSelect(IRuntimeJewel jewel)
        {
            // Check to see if an action is about to be run
            if (BoardController.Instance.IsWaitingForAction())
            {
                GameEvents.Instance.Notify <IInvokeActionBoard>(i => i.OnInvokeBoardActionCheck(jewel));
            }
            else
            {
                // Select jewel
                jewel.DoSelect();

                // Right here is where I need to look through all the jewels and see if two jewels are clicked
                GameEvents.Instance.Notify <ISelectedBoard>(i => i.OnBoardSelectedCheck());
            }
        }
Exemplo n.º 21
0
        public override bool Execute(IRuntimeJewel TriggerJewel)
        {
            Debug.Log("Execute Pop Effect!");
            if (TriggerJewel.Data.JewelID != Jewel)
            {
                return(false);
            }

            // Find all jewels of type
            List <IRuntimeJewel> matching = new List <IRuntimeJewel>();

            // Make sure the jewel clicked is the correct jewel for the effect

            // Pop in a radius between min and max
            int radius = Random.Range(MinAmt, MaxAmt);

            // Get gameboard
            IRuntimeJewel[,] board = GameData.Instance.RuntimeGame.GameBoard.GetBoardData().GetMap();

            int width  = board.GetLength(0);
            int height = board.GetLength(1);

            for (int x = (int)TriggerJewel.Pos.x - radius; x <= (int)TriggerJewel.Pos.x + radius; x++)
            {
                for (int y = (int)TriggerJewel.Pos.y - radius; y <= (int)TriggerJewel.Pos.y + radius; y++)
                {
                    if (x >= 0 && x < width && y >= 0 && y < height)
                    {
                        matching.Add(board[x, y]);
                    }
                }
            }

            // Destroy jewels in list
            foreach (IRuntimeJewel jwl in matching)
            {
                //GameData.Instance.RuntimeGame.GameBoard.GetBoardData().SetJewel(null, jwl.Pos);
                GameEvents.Instance.Notify <IRemoveJewel>(i => i.OnRemoveJewel(jwl));
            }

            return(true);
        }
Exemplo n.º 22
0
        public IUiJewel Get(IRuntimeJewel jewel)
        {
            var obj = Get <IUiJewel>();

            obj.UIRuntimeData.SetData(jewel);
            //obj.SetData(jewel);

            //.Data.SetData(jewel);
            //busyObjects[prefabModel].Add(pooledObj);

            //pooledObj.SetActive(true);
            //OnPool(pooledObj);

            //return pooledObj;

            //GameObject instantiatedJewel = Instantiate(modelsPooled[0], transform);
            //instantiatedJewel.SetActive(true);
            //base.OnPool(instantiatedJewel);
            //IUiJewel uiJewel = instantiatedJewel.GetComponent<IUiJewel>();
            return(obj);
        }
Exemplo n.º 23
0
        public static List <SwapChoices> FindBestMatches(IRuntimeJewel[,] jewelMap, List <JewelID> prefJewels = null)
        {
            int width  = jewelMap.GetLength(0);
            int height = jewelMap.GetLength(1);

            List <SwapChoices> options = new List <SwapChoices>();

            // Look at all the rows and remove gems that are in the buffer more than 3
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width - 1; x++)
                {
                    IRuntimeJewel j1 = jewelMap[x, y];
                    IRuntimeJewel j2 = jewelMap[x + 1, y];

                    int matchcount = WillCauseMatchCount(jewelMap, j1, j2, prefJewels);
                    if (matchcount > 0)
                    {
                        options.Add(new SwapChoices(j1, j2, matchcount));
                    }
                }
            }

            // Look at all the columns and remove gems that are in the buffer more than 3
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height - 1; y++)
                {
                    IRuntimeJewel j1 = jewelMap[x, y];
                    IRuntimeJewel j2 = jewelMap[x, y + 1];

                    int matchcount = WillCauseMatchCount(jewelMap, j1, j2, prefJewels);
                    if (matchcount > 0)
                    {
                        options.Add(new SwapChoices(j1, j2, matchcount));
                    }
                }
            }
            return(options);
        }
Exemplo n.º 24
0
        private IEnumerator CascadeJewelFromQueue()
        {
            IRuntimeJewel jq = JewelsToFall.Dequeue();

            Vector2 BoardTo   = BoardPos.OffsetJewelByPosition(jq.Pos);
            Vector2 BoardFrom = BoardPos.OffsetJewelByPosition(jq.LastPos);

            Vector3 to   = BoardPos.GetNextJewelPosition(BoardTo, utils.DeckPosition.position);
            Vector3 from = jq.IsNew() ? new Vector3(to.x, BoardPos.GetBoardTopPos().y, to.z)
        : new Vector3(to.x, BoardPos.GetNextJewelPosition(BoardFrom, utils.DeckPosition.position).y, to.z);

            if (jq.IsNew())
            {
                var uiJewel             = UiJewelPool.Instance.Get(jq);
                IUiJewelComponents comp = uiJewel.MonoBehavior.GetComponent <IUiJewelComponents>();
                //comp.UIRuntimeData.OnSetData(jq);
                uiJewel.MonoBehavior.name  = jq.JewelID;
                uiJewel.transform.position = from;
                utils.PlayerBoard.AddJewel(uiJewel);
            }

            yield return(new WaitForSeconds(utils.JEWELFALLDELAY));

            if (jq.IsNew() || jq.LastPos.y != jq.Pos.y)
            {
                OnNotifyPositionChange(jq, from, to);
            }

            if (JewelsToFall.Count > 0)
            {
                JewelsFalling = utils.MBehaviour.StartCoroutine(CascadeJewelFromQueue());
            }
            else
            {
                yield return(new WaitForSeconds(.2f));

                CheckEndCascade();
            }
        }
Exemplo n.º 25
0
 public void OnJewelPosition(IRuntimeJewel Jewel, Vector3 from, Vector3 to)
 {
     /*
      * Here is where we need to query the board map holder and make sure that
      * this gem is the gem that is supposed to be in the position
      */
     if (jewel.JewelID == Jewel.JewelID)
     {
         IRuntimeJewel[,] board = GameData.Instance.RuntimeGame.GameBoard.GetBoardData().GetMap();
         IRuntimeJewel boardJewel = board[(int)jewel.Pos.x, (int)jewel.Pos.y];
         if (boardJewel.JewelID == jewel.JewelID)
         {
             // The board and the cascader are in sync, move jewel to correct position
             parent.MonoBehavior.StartCoroutine(CascadeJewelFromPosition(from, to));
         }
         else
         {
             // The board and the cascader are out of sync, and this jewel should have been deleted
             parent.OnRemove(jewel);
         }
     }
 }
Exemplo n.º 26
0
        public override bool Execute(IRuntimeJewel TriggerJewel)
        {
            // Get gameboard
            IRuntimeJewel[,] board = GameData.Instance.RuntimeGame.GameBoard.GetBoardData().GetMap();

            // Find all jewels of type
            List <IRuntimeJewel> matching = new List <IRuntimeJewel>();

            int width  = board.GetLength(0);
            int height = board.GetLength(1);

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    if (board[x, y].Data.JewelID == Jewel || Jewel == JewelID.any)
                    {
                        matching.Add(board[x, y]);
                    }
                }
            }

            // Pick out the right jewels in range
            // -1 values in MinAmt or MaxAmt will destroy all of type Jewel
            if (MinAmt != -1 && MaxAmt != -1)
            {
                int amt = Random.Range(MinAmt, MaxAmt);
                ListExtensions.Shuffle(matching);
                matching = matching.Take(amt).ToList();
            }

            // Destroy jewels in list
            foreach (IRuntimeJewel jwl in matching)
            {
                GameEvents.Instance.Notify <ITransformJewel>(i => i.OnTransformJewel(jwl, TransformJewel));
            }

            return(true);
        }
Exemplo n.º 27
0
 private void OnSwapJewel(IRuntimeJewel jewel, IRuntimeJewel jewel2)
 {
     GameEvents.Instance.Notify <ISwapJewel>(i => i.OnJewelSwap(jewel, jewel2));
 }
Exemplo n.º 28
0
 private void SetJewelData(IRuntimeJewel jewel, Vector2 pos)
 {
     board.GetBoardData().SetJewel(jewel, pos);
 }
Exemplo n.º 29
0
 public void OnUnselect(IRuntimeJewel Jewel)
 {
     jewel.IsSelected = false;
 }
Exemplo n.º 30
0
 public UnselectJewelMechanics(IRuntimeJewel jewel) : base(jewel)
 {
     this.jewel             = jewel;
     this.jewel.OnUnSelect += OnUnselect;
 }