Beispiel #1
0
        /*
         * Returns a value between 0 and 1 representing the density of enemies or teammates near this pos.
         */
        public float TeamDensity(BasicUnit b, bool returnSameTeam)
        {
            var pos  = b.pos;
            var team = b.team;

            var val = 0.0f;

            for (int i = 1; i < 10; i++)
            {
                for (int x = -1; x < 2; x++)
                {
                    for (int y = -1; y < 2; y++)
                    {
                        if (x == 0 && y == 0)
                        {
                            continue;
                        }
                        var checkPos = new Vector2Int(pos.x + x * i, pos.y + y * i);
                        if (OOB(checkPos))
                        {
                            continue;
                        }

                        if (returnSameTeam)
                        {
                            if (!team.IsEnemy(Get(checkPos)))
                            {
                                val += (10 - i);
                            }
                        }
                        else
                        {
                            if (team.IsEnemy(Get(checkPos)))
                            {
                                val += (10 - i);
                            }
                        }
                    }
                }
            }
            if (val > 360)
            {
                Debug.LogError("team density not working");
            }
            return(val / 360.0f);
        }
Beispiel #2
0
        public bool Move(BasicUnit basicUnit, Vector2Int move)
        {
            var basicUnitPos = basicUnit.pos + move;

            if (OOB(basicUnitPos))
            {
                return(false);
            }
            if (map[basicUnitPos.x, basicUnitPos.y] != null)
            {
                return(false);
            }
            else
            {
                map[basicUnitPos.x, basicUnitPos.y]   = basicUnit;
                map[basicUnit.pos.x, basicUnit.pos.y] = null;
                basicUnit.pos = basicUnitPos;
                return(true);
            }
        }
Beispiel #3
0
 public bool AttemptRetreat(BasicUnit basicUnit)
 {
     throw new NotImplementedException();
 }