Пример #1
0
        private void ProcessModifyAttackEvent(ModifyAttackEvent kEvent)
        {
            KVector2 kEventPosition = kEvent.position;
            var      clientFruiton  = FruitonsGrid[kEventPosition.x, kEventPosition.y].GetComponent <ClientFruiton>();

            clientFruiton.ModifyAttack(kEvent.newAttack);
        }
Пример #2
0
        private void ProcessAttackEvent(AttackEvent kEvent)
        {
            KVector2   attackerPosition = kEvent.source;
            GameObject attacker         = FruitonsGrid[attackerPosition.x, attackerPosition.y];

            attacker.GetComponentInChildren <BoyFighterBattleAnimator>().Attack(() => AfterAttackAnimation(kEvent));
        }
Пример #3
0
        private void ProcessHealEvent(HealEvent kEvent)
        {
            KVector2   healerPosition = kEvent.source;
            GameObject attacker       = FruitonsGrid[healerPosition.x, healerPosition.y];

            attacker.GetComponentInChildren <BoyFighterBattleAnimator>().Cast(() => AfterHealAnimation(kEvent));
        }
Пример #4
0
        private void AfterHealAnimation(HealEvent kEvent)
        {
            KVector2 kEventPosition = kEvent.target;
            var      clientFruiton  = FruitonsGrid[kEventPosition.x, kEventPosition.y].GetComponent <ClientFruiton>();

            clientFruiton.ReceiveHeal(kEvent.heal);
            ShowFloatingText(clientFruiton.transform.position, kEvent.heal);
        }
Пример #5
0
        private void VisualizePossibleAttacks(KVector2 potentialPosition, KFruiton kernelFruiton)
        {
            var potentialTargets = battle.ComputePossibleAttacks(potentialPosition, kernelFruiton);

            foreach (var potentialTarget in potentialTargets)
            {
                if (!GridLayoutManager.IsTileAttack(potentialTarget.x, potentialTarget.y))
                {
                    GridLayoutManager.HighlightCell(potentialTarget.x, potentialTarget.y, Color.yellow);
                }
            }
        }
Пример #6
0
        private void ProcessMoveEvent(MoveEvent moveEvent)
        {
            IsInputEnabled = false;
            KVector2   from        = moveEvent.from;
            KVector2   to          = moveEvent.to;
            GameObject movedObject = FruitonsGrid[from.x, from.y];

            FruitonsGrid[to.x, to.y]     = movedObject;
            FruitonsGrid[from.x, from.y] = null;
            moveCoroutine = StartCoroutine(MoveCoroutine(movedObject.transform.position, to, movedObject));
            GridLayoutManager.ResetHighlights();
        }
Пример #7
0
        private void AfterAttackAnimation(AttackEvent kEvent)
        {
            KVector2   damagedPosition      = kEvent.target;
            GameObject damaged              = FruitonsGrid[damagedPosition.x, damagedPosition.y];
            Vector3    damagedWorldPosition = GridLayoutManager.GetCellPosition(damagedPosition.x, damagedPosition.y);

            if (damaged != null)
            {
                damaged.GetComponent <ClientFruiton>().TakeDamage(kEvent.damage);
            }

            ShowFloatingText(damagedWorldPosition, -kEvent.damage);
        }
Пример #8
0
        public void HoverLogic()
        {
            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            RaycastHit[] raycastHits = Physics.RaycastAll(ray);
            RaycastHit   tileHit     = raycastHits.FirstOrDefault(hit => GridLayoutManager.ContainsTile(hit.transform.gameObject));

            if (!tileHit.Equals(default(RaycastHit)))
            {
                KVector2   tilePosition = GridLayoutManager.GetIndicesOfTile(tileHit.transform.gameObject);
                GameObject hitFruiton   = FruitonsGrid[tilePosition.x, tilePosition.y];
                if (hitFruiton != null)
                {
                    UpdateAndShowTooltip(hitFruiton);
                    return;
                }
            }
            FruitonInfoPanel.SetActive(false);
        }
Пример #9
0
        private IEnumerator MoveCoroutine(Vector3 from, KVector2 toCoordinates, GameObject movedObject)
        {
            var     anim     = movedObject.GetComponentInChildren <FruitonBattleAnimator>();
            Vector3 toGlobal = GridLayoutManager.GetCellPosition(toCoordinates.x, toCoordinates.y);
            Vector3 toLocal  = movedObject.transform.parent.transform.InverseTransformPoint(toGlobal);

            bool isFlipped = false;

            if ((anim.SkeletonAnim.Skeleton.FlipX && from.z > toGlobal.z ||
                 !anim.SkeletonAnim.Skeleton.FlipX && from.z < toGlobal.z))
            {
                isFlipped = true;
                anim.SkeletonAnim.Skeleton.FlipX = !anim.SkeletonAnim.Skeleton.FlipX;
            }

            Vector3 direction  = toGlobal - from;
            Vector3 moveVector = 5 * direction.normalized;

            anim.StartWalking();

            float distance, previousDistance = float.MaxValue;

            while ((distance = Vector3.Distance(movedObject.transform.localPosition, toLocal)) > 0.05f &&
                   distance <= previousDistance) // Are we still going closer?
            {
                previousDistance = distance;
                movedObject.transform.localPosition += moveVector * Time.deltaTime;
                yield return(null);
            }

            movedObject.transform.localPosition = toLocal; // Always make sure we made it exactly there
            anim.StopWalking();
            if (isFlipped)
            {
                anim.SkeletonAnim.Skeleton.FlipX = !anim.SkeletonAnim.Skeleton.FlipX;
            }

            IsInputEnabled = true;
        }
Пример #10
0
        public LazyDictionary <int, List <TargetableAction> > VisualizeAvailableTargetableActions(KVector2 indices)
        {
            var           result        = new LazyDictionary <int, List <TargetableAction> >();
            List <Action> allActions    = battle.GetAllValidActionFrom(indices);
            Fruiton       kernelFruiton = battle.GetFruiton(indices);

            foreach (Action action in allActions)
            {
                VisualizeAction(action, kernelFruiton);
                TargetableAction castAction = action as TargetableAction;
                if (castAction != null)
                {
                    result[action.getId()].Add(castAction);
                }
            }
            return(result);
        }
Пример #11
0
 public static Position ToPosition(this KVector2 kernelPoint)
 {
     return(new Position {
         X = kernelPoint.x, Y = kernelPoint.y
     });
 }