Exemplo n.º 1
0
 public Track Extend(int newInd)
 {
     Track extendedTrack = new Track(waver);
     extendedTrack.track.AddRange(track);
     extendedTrack.track.Add(newInd);
     extendedTrack.waver = waver;
     return extendedTrack;
 }
Exemplo n.º 2
0
 public Track Clone()
 {
     Track clone = new Track(waver);
     clone.track.AddRange(track);
     clone.grade = grade;
     clone.makeHaste = makeHaste;
     return clone;
 }
Exemplo n.º 3
0
 public static int CompareTracks(Track a, Track b)
 {
     return b.grade - a.grade;
 }
Exemplo n.º 4
0
        public int WaverIsSPIsTooClose(int p1SPInd, int p2SPInd, Track track)
        {
            int minDistToSP1 = GetBlockDistance(p1SPInd, track.PeekNext());
            int minDistToSP2 = GetBlockDistance(p2SPInd, track.PeekNext());
            for (int i = 1; i < track.Length(); ++i)
            {
                minDistToSP1 = System.Math.Min(minDistToSP1, GetBlockDistance(p1SPInd, track.Peek(i)));
                minDistToSP2 = System.Math.Min(minDistToSP2, GetBlockDistance(p2SPInd, track.Peek(i)));
            }

            int distLimit = STAY_AWAY_FROM_SP_DIST_DEFENSIVE;
            bool SP1IsClose = minDistToSP1 < distLimit;
            bool SP2IsClose = minDistToSP1 < distLimit;
            int val1 = SP1IsClose ? -distLimit + minDistToSP1 : 0;
            int val2 = SP2IsClose ? -distLimit + minDistToSP2 : 0;
            return System.Math.Min(val1, val2);
        }
Exemplo n.º 5
0
        // 0 - not passable, 1 - rotating, 2 - empty (passable))
        // returns true if atleas one track exists
        public bool StartWave(int start, int[,] map)
        {
            //Debug.Log(string.Format("start {0}", start));
            tracks.Clear();
            completeTracks.Clear();

            Track stratTrack = new Track(start, this);
            tracks.Add(stratTrack);

            int[] neighbours = new int[4] { 0, 0, 0, 0 };

            while (tracks.Count > 0 && tracks[0].CanExtend())
            {
                Track nextTrack = tracks[0];
                tracks.RemoveAt(0);
                int endBlock = nextTrack.GetLast();
                int neighbourCnt = FindNeightbourBlocks(endBlock, ref neighbours);
                bool foundNeighbour = false;
                for (int i = 0; i < neighbourCnt; ++i)
                {
                    System.Diagnostics.Debug.Assert(neighbours[i] >= 0 && neighbours[i] < AI.MapSize);
                    bool passable = PassableBlock(map, neighbours[i]);
                    bool notIn = !nextTrack.HasBlock(neighbours[i]);
                    //UnityEngine.Debug.Log(string.Format("n {0} {1} {2} {3}", i, neighbours[i], passable, notIn));
                    if (passable && notIn)
                    {
                        foundNeighbour = true;
                        tracks.Add(nextTrack.Extend(neighbours[i]));
                    }
                }
                if (!foundNeighbour && nextTrack.Length() > 1)
                {
                    System.Diagnostics.Debug.Assert(nextTrack.Length() > 0);
                    completeTracks.Add(nextTrack);
                }
            }

            foreach (Track track in tracks)
            {
                if (track.Length() > 1)
                {
                    System.Diagnostics.Debug.Assert(track.Length() > 0);
                    completeTracks.Add(track);
                }
            }

            // pop away the start block
            foreach (Track track in completeTracks)
            {
                track.PopNext();
            }

            needsRun = false;
            return completeTracks.Count > 0;
        }