Exemplo n.º 1
0
        public static int TracePath(Vector2 fromPos, Vector2 toPos, PlayerTeam team, bool fullCheck = false)
        {
            int     width      = 4;
            float   angle      = TwoPointAngle(fromPos, toPos);
            Vector2 diff       = toPos - fromPos;
            float   offsetX    = (float)Math.Cos(angle) * (width + 8);
            float   offsetY    = (float)Math.Sin(angle) * (width + 8);
            int     itCount    = (int)Math.Ceiling(diff.X / offsetX);
            Vector2 currentPos = fromPos;
            int     vision     = 0;

            for (int i = 0; i < itCount; i++)
            {
                Area      area    = new Area(currentPos.Y + width / 2.0f, currentPos.X - width / 2.0f, currentPos.Y - width / 2.0f, currentPos.X + width / 2.0f);
                IObject[] objList = GlobalGame.GetObjectsByArea(area);
                for (int j = 0; j < objList.Length; j++)
                {
                    string name = objList[j].Name;
                    if (name.StartsWith("Bg") || name.StartsWith("FarBg"))
                    {
                        continue;
                    }
                    if (IsPlayer(name))
                    {
                        TPlayer pl = GetPlayer((IPlayer)objList[j]);
                        if (pl.IsAlive() && !fullCheck)
                        {
                            if (pl.Team == team)
                            {
                                vision = 3;
                            }
                            else
                            {
                                return(vision);
                            }
                        }
                        else
                        {
                            vision = Math.Max(vision, 1);
                        }
                    }
                    else if (VisionObjects.ContainsKey(name))
                    {
                        vision = Math.Max(vision, VisionObjects[name]);
                    }
                    if (vision >= 3)
                    {
                        return(vision);
                    }
                }
                currentPos.X += offsetX;
                currentPos.Y += offsetY;
            }
            return(vision);
        }
Exemplo n.º 2
0
 public static bool CheckAreaToCollision(Area area)
 {
     IObject[] objList = GlobalGame.GetObjectsByArea(area);
     for (int j = 0; j < objList.Length; j++)
     {
         string name = objList[j].Name;
         if (name.StartsWith("Bg") || name.StartsWith("FarBg"))
         {
             continue;
         }
         if (VisionObjects.ContainsKey(name))
         {
             return(true);
         }
     }
     return(false);
 }