Ejemplo n.º 1
0
        public Map(string file)
        {
            Stream       stream = File.Open(basePath + file, FileMode.Open);
            BinaryReader reader = new BinaryReader(stream);

            try
            {
                sizeX = reader.ReadSingle();
                sizeY = reader.ReadSingle();
                int numBushes = reader.ReadInt32();
                bushes = new Bush[numBushes];
                for (int x = 0; x < numBushes; x++)
                {
                    bushes[x] = new Bush(reader);
                }

                int numCollisions = reader.ReadInt32();
                collisions = new Collision[numCollisions];
                for (int x = 0; x < numCollisions; x++)
                {
                    collisions[x] = new Collision(reader);
                }

                int numStructures = reader.ReadInt32();
                structures = new Structure[numStructures];
                for (int x = 0; x < numStructures; x++)
                {
                    int type = reader.ReadInt32();
                    switch ((StructureType)type)
                    {
                    case StructureType.Turret: structures[x] = new Turret(this, reader); break;

                    case StructureType.Nexus: structures[x] = new Nexus(this, reader); break;
                    }
                }

                int numLanes = reader.ReadInt32();
                lanes = new Lane[numLanes];
                for (int x = 0; x < numLanes; x++)
                {
                    lanes[x] = new Lane(reader);
                }
            }
            finally
            {
                reader.Close();
                stream.Close();
            }
            Initialize();
        }
Ejemplo n.º 2
0
Archivo: Map.cs Proyecto: MyEyes/MobaAI
        public Map(string file)
        {
            Stream stream = File.Open(basePath + file, FileMode.Open);
            BinaryReader reader = new BinaryReader(stream);
            try
            {
                sizeX = reader.ReadSingle();
                sizeY = reader.ReadSingle();
                int numBushes = reader.ReadInt32();
                bushes = new Bush[numBushes];
                for (int x = 0; x < numBushes; x++)
                    bushes[x] = new Bush(reader);

                int numCollisions = reader.ReadInt32();
                collisions = new Collision[numCollisions];
                for (int x = 0; x < numCollisions; x++)
                    collisions[x] = new Collision(reader);

                int numStructures = reader.ReadInt32();
                structures = new Structure[numStructures];
                for (int x = 0; x < numStructures; x++)
                {
                    int type = reader.ReadInt32();
                    switch ((StructureType)type)
                    {
                        case StructureType.Turret: structures[x] = new Turret(this, reader); break;
                        case StructureType.Nexus: structures[x] = new Nexus(this, reader); break;
                    }

                }

                int numLanes = reader.ReadInt32();
                lanes = new Lane[numLanes];
                for (int x = 0; x < numLanes; x++)
                    lanes[x] = new Lane(reader);
            }
            finally
            {
                reader.Close();
                stream.Close();
            }
            Initialize();
        }
Ejemplo n.º 3
0
 public Minion(Map map, Lane lane, Team team, CharacterInfo info, Vector3 position)
     : base(map, team, info, position)
 {
     this.lane  = lane;
     nextTarget = lane.Waypoints[1];
 }
Ejemplo n.º 4
0
 public Minion(Map map, Lane lane, Team team, CharacterInfo info, Vector3 position)
     : base(map, team, info, position)
 {
     this.lane = lane;
     nextTarget = lane.Waypoints[1];
 }
Ejemplo n.º 5
0
Archivo: Map.cs Proyecto: MyEyes/MobaAI
 public void SetLanes(Lane[] lanes)
 {
     this.lanes = lanes;
 }
Ejemplo n.º 6
0
        public void LaneUpdate(float dt)
        {
            if (currentLane == null)
            {
                Team team = champion.GetTeam();
                targetID = 0;
                int index = MobaGame.random.Next(map.Lanes.Length);
                if (map.Lanes[index].Team == team)
                    currentLane = map.Lanes[index];
                if (currentLane != null)
                    nextTarget = currentLane.Waypoints[0];
            }

            targetPos = nextTarget;
            Vector3 diff = nextTarget - champion.GetPosition();
            float length = diff.Length();
            diff /= length;
            if (length < 5)
            {
                targetID++;
                if (targetID >= currentLane.Waypoints.Length)
                    targetID = currentLane.Waypoints.Length - 1;
                nextTarget = currentLane.Waypoints[targetID];
            }

            TryFindTarget();
            if (currentEnemy != null)
                state = TestControllerState.Attacking;
        }
Ejemplo n.º 7
0
        public void RetreatUpdate(float dt)
        {
            if(EnemyInRange(champion.GetInfo().viewRadius) && currentLane!=null)
            {
                targetPos = nextTarget;
                Vector3 diff = nextTarget - champion.GetPosition();
                float length = diff.Length();
                diff /= length;
                if (length < 5)
                {
                    targetID--;
                    if (targetID < 0)
                        targetID = 0;
                    nextTarget = currentLane.Waypoints[targetID];
                }
            }
            else
            {
                if (!champion.GoingBack)
                {
                    champion.GoBack();
                    targetPos = champion.GetPosition();
                }
            }

            if (champion.GetHealth() > champion.GetInfo().maxHealth * 0.4f)
            {
                currentLane = null;
                targetID = 0;
                state = TestControllerState.Laning;
            }
        }