예제 #1
0
 public virtual void DestroyTerrain()
 {
     crackedMesh?.SplitMesh();
     OnDeathSound?.PlayAudio();
     UnitsMap.Remove(this.GetPosition());
     EnvironmentManager.EnvironmentCollection.Remove(WorldPosition);
     gameObject.SetActive(false);
 }
예제 #2
0
        private void SimulateAttack(bool highlight)
        {
            List <Unit> playerUnits = this.UnitsMap.GetUnits(Type.Player);
            List <Unit> enemyUnits  = UnitsMap.GetUnits(Type.Enemy);

            enemyUnits.ForEach(unit => SimulateAttack(highlight, unit.GetPosition(), 0, -this.Knockback, false));
            playerUnits.ForEach(unit => SimulateAttack(highlight, unit.GetPosition(), this.DeltaHealth, -this.Knockback, false));
        }
예제 #3
0
        private void PullAll()
        {
            KnockbackHandler handler    = new KnockbackHandler(this.Unit.UnitsMap);
            List <Unit>      enemyUnits = UnitsMap.GetUnits(Type.Enemy);

            enemyUnits.AddRange(UnitsMap.GetUnits(Type.Player));
            enemyUnits.ForEach(enemyUnit => this.PullUnit(handler, enemyUnit));
        }
예제 #4
0
        protected override void AttackPositions(Point point)
        {
            base.AttackPositions(point);
            if (!UnitsMap.Contains(point))
            {
                return;
            }

            SkillActionFX?.Play(UnitsMap.Get(point).gameObject.transform.position);
        }
예제 #5
0
 public override void DestroyTerrain()
 {
     if (Health.IsDead())
     {
         UnitsMap.Remove(GetPosition());
         Spawner.SpawnUnit(SpawnedUnit, this.WorldPosition);
         EnvironmentManager.EnvironmentCollection.Remove(WorldPosition);
         gameObject.SetActive(false);
     }
 }
예제 #6
0
        public void SetUp(UnitsMap unitsMap, BoardController boardController, Point attackerPosition, int knockback, int damage)
        {
            DamageOnCollision bullet = this.GetComponent <DamageOnCollision>();

            bullet.Damage           = damage;
            bullet.UnitsMap         = unitsMap;
            bullet.BoardController  = boardController;
            bullet.AttackerPoint    = attackerPosition;
            bullet.Knockback        = knockback;
            bullet.DestroyComponent = true;
        }
예제 #7
0
        public void SetUp(BoardController boardController, UnitsMap unitsMap, int damage, int knockback, Point origin)
        {
            DamageOnCollision onCollision = this.GetComponent <DamageOnCollision>();

            Logcat.I($"HoloblastSplit damage {damage}, unitsMap {unitsMap}, knockback {knockback} attacker position {origin}");
            onCollision.BoardController = boardController;
            onCollision.UnitsMap        = unitsMap;
            onCollision.Damage          = damage;
            onCollision.Knockback       = knockback;
            onCollision.AttackerPoint   = origin;
        }
예제 #8
0
        public override void Execute()
        {
            Logcat.I(this, $"Incarnate IncarnateRebirthAttackAction execute");
            base.Execute();
            if (IsAnExcludedEnemy())
            {
                return;
            }

            UnitsMap.Remove(this.Unit.GetPosition());
            StartCoroutine(Rebirth());
        }
예제 #9
0
        private IEnumerator Attack(CardinalDirections direction, Vector3 point)
        {
            yield return(new WaitForSeconds(delay));

            Logcat.I(this, $"Shooting with direction {direction} vector {point}");
            this.transform.localPosition += point;
            GetPointsInLine(direction)?.ForEach(p => UnitsMap.Get(p)?.Health?.ReduceHealth(this.DeltaHealth));
            this.transform.localPosition -= point;
            KnockbackHandler handler = new KnockbackHandler(this.UnitsMap);

            handler.Execute(this.BoardController, Target, this.Unit.GetPosition(), this.Knockback);
        }
예제 #10
0
        protected virtual void AttackPositions(Point point)
        {
            if (!UnitsMap.Contains(point))
            {
                return;
            }

            Unit             targetUnit = this.UnitsMap.Get(point);
            KnockbackHandler handler    = new KnockbackHandler(this.UnitsMap);

            handler.Execute(this.BoardController, this.Unit.GetPosition(), targetUnit.GetPosition(), this.Knockback);
            targetUnit?.Health.ReduceHealth(this.DeltaHealth);
        }
예제 #11
0
        public static KeyValuePair <Point, int> GetClosestTarget(UnitsMap unitsMap, Point unitPosition, int range)
        {
            Dictionary <Point, int> playerUnits = new Dictionary <Point, int>();

            foreach (var playerUnit in unitsMap.GetUnits(Type.Player))
            {
                int distance = PointUtils.GetDistance(unitPosition, playerUnit.GetPosition());
                playerUnits.Add(playerUnit.GetPosition(), distance);
            }

            var orderer = playerUnits.OrderByDescending(unit => unit.Value);

            if (orderer == null || orderer.Count() == 0)
            {
                return(default);
예제 #12
0
        public virtual void SetUp(UnitsMap map, BoardController boardController, Point attackerPosition, CardinalDirections[] blastSplit, int firstAttackDamage, int secondAttackDamage, int knockback)
        {
            this.unitsMap           = map;
            this.boardController    = boardController;
            this.blastSplit         = blastSplit;
            this.secondAttackDamage = secondAttackDamage;
            this.secondKnockback    = knockback;
            DamageOnCollision bullet = this.GetComponent <DamageOnCollision>();

            bullet.UnitsMap         = map;
            bullet.BoardController  = boardController;
            bullet.AttackerPoint    = attackerPosition;
            bullet.Knockback        = knockback;
            bullet.Damage           = firstAttackDamage;
            bullet.DestroyComponent = false;
        }
예제 #13
0
        private void SpawnSplit(UnitsMap map, BoardController boardController, CardinalDirections direction, Point attackerPosition)
        {
            if (InstantiatedSplits >= maxSplits)
            {
                return;
            }

            InstantiatedSplits++;
            Logcat.I(this, $"Multisplit instances {InstantiatedSplits}");

            CardinalDirections[] directions = PlayerUtils.HoloBlastSplitDirections(direction);
            Vector3 position = PointConverter.ToVector(attackerPosition) + PointConverter.ToVector(Direction.GetDirection(direction));

            position.y = fixedPosition;
            Quaternion rotation = RotationHelper.GetRotation(direction);
            MultiSplit instance = Instantiate(split, position, rotation);

            instance.SetUp(this.unitsMap, boardController, attackerPosition, directions, secondAttackDamage, secondAttackDamage, knockback);
        }
예제 #14
0
    private IEnumerator ApplyExplosion(Point[] targets, Point[] attackArea)
    {
        yield return(new WaitForSeconds(HighlightWaitTime));

        foreach (Point item in targets)
        {
            if (UnitsMap.Contains(item))
            {
                Unit targetUnit = UnitsMap.Get(item);
                targetUnit.Health.ReduceHealth(Damage);
                handler.Execute(controller, this.GetPosition(), targetUnit.GetPosition(), 1);
            }
        }

        controller.SwitchTilesFromActiveBoards(new HashSet <Point>(attackArea), Edu.Vfs.RoboRapture.TileAuxillary.TileStates.NORMAL);

        EnvironmentManager.EnvironmentCollection.Remove(WorldPosition);
        UnitsMap.Remove(this.GetPosition());
        gameObject.SetActive(false);
    }
예제 #15
0
    public void Explode()
    {
        List <Point> foundTargets = new List <Point>();

        // TODO: Query Units Map for all surrounding units. in the cardinal directions
        foreach (Point item in attackArea)
        {
            if (UnitsMap.Contains(item))
            {
                foundTargets.Add(item);
            }

            controller.SwitchTilesFromActiveBoards(new HashSet <Point>(attackArea), Edu.Vfs.RoboRapture.TileAuxillary.TileStates.ATTACK);
        }

        // TODO: Apply target highlight to surrounding tiles and attack highlight.

        foreach (Point item in foundTargets)
        {
            controller.SwitchTilesFromActiveBoards(new HashSet <Point>(attackArea), Edu.Vfs.RoboRapture.TileAuxillary.TileStates.TARGET);
        }

        StartCoroutine(ApplyExplosion(foundTargets.ToArray(), attackArea.ToArray()));
    }
예제 #16
0
        private string ConvertNumbersToWords(int value)
        {
            if (value == 0)
            {
                return("zero");
            }

            if (value < 0)
            {
                return("menos " + ConvertNumbersToWords(Math.Abs(value)));
            }

            string words = "";

            if ((value / 1000000) > 0)
            {
                var million = value / 1000000;
                words += ConvertNumbersToWords(million) + (million > 1 ? " milhões " : " milhão ");
                value %= 1000000;
            }

            if ((value / 1000) > 0)
            {
                words += ConvertNumbersToWords(value / 1000) + " mil ";
                value %= 1000;
            }

            if ((value / 100) > 0)
            {
                string houndredsWord = HoundredsMap.GetFromPosition(value / 100);
                value %= 100;
                if (value > 0 && houndredsWord == "cem")
                {
                    houndredsWord = " cento ";
                }

                words += houndredsWord;
            }

            if (value > 0)
            {
                if (words != "")
                {
                    words += "e ";
                }

                if (value < 20)
                {
                    words += UnitsMap.GetFromPosition(value);
                }
                else
                {
                    words += TensMap.GetFromPosition(value / 10);
                    if ((value % 10) > 0)
                    {
                        words += " e " + UnitsMap.GetFromPosition(value % 10);
                    }
                }
            }

            return(words);
        }
예제 #17
0
 public InitialPlacementValidator(UnitsMap map, Point point)
 {
     this.map   = map;
     this.point = point;
 }
예제 #18
0
        public static Dictionary <Point, List <Point> > GetAllPaths(List <Point> board, UnitsMap unitsMap, Point unitPosition, bool excludePlayerUnits)
        {
            if (board == null || unitsMap == null)
            {
                return(new Dictionary <Point, List <Point> >());
            }

            int          distance      = 0;
            int          patternSize   = 7;
            int          stepsLimit    = 17;
            List <Point> boardPoints   = PatternProcessor.Process(board, new SquarePattern(patternSize), unitPosition, distance);
            List <Point> processedList = boardPoints.Where(currentPoint => !unitsMap.Contains(currentPoint)).ToList();

            if (!excludePlayerUnits)
            {
                unitsMap.GetUnits(Type.Player).ForEach(unit => processedList.Add(unit.GetPosition()));
            }

            return(BFS.GetPaths(processedList, unitPosition, stepsLimit));
        }
예제 #19
0
        public static Dictionary <Point, List <Point> > GetAllPaths(List <Point> board, UnitsMap unitsMap, Point unitPosition)
        {
            if (board == null || unitsMap == null)
            {
                return(new Dictionary <Point, List <Point> >());
            }

            int          distance    = 0;
            int          patternSize = 7;
            int          stepsLimit  = 17;
            List <Point> boardPoints = PatternProcessor.Process(board, new SquarePattern(patternSize), unitPosition, distance);

            return(BFS.GetPaths(boardPoints, unitPosition, stepsLimit));
        }