Пример #1
0
    /*
     * Tracks where the players go to then draw a line of claimed tiles
     * the line is being tracked by start and end position
     * when the end is determined all claimed will be send over to Claimed()
     */
    void TrackClaim(Transform _player)
    {
        int _x = Mathf.RoundToInt(_player.position.x / tilewidth);
        int _y = -Mathf.RoundToInt(_player.position.y / tileheight);

        NeuralTubePlayer player = _player.GetComponent <NeuralTubePlayer> ();

        if (map[_y, _x] == 0)
        {
            if (player.tracking)
            {
                map[_y, _x] = 6;
                player.path.Add(new Vector2(_y, _x));
                tilemap[_y, _x].GetComponent <NeuralTubeAreaClaim> ().Claim();
                if (CheckArea(_y, _x) > 0)
                {
                    Claimed(player);
                    player.tracking = false;
                }
            }
            else
            {
                if (CheckArea(_y, _x) > 0)
                {
                    map[_y, _x] = 6;
                    player.path.Add(new Vector2(_y, _x));
                    tilemap[_y, _x].GetComponent <NeuralTubeAreaClaim> ().Claim();
                    player.tracking = true;
                }
            }
        }
    }
Пример #2
0
 /*
  * When an enemy runs into a player's claim path,
  * the content of the path should be removed
  */
 void UnClaim(NeuralTubePlayer _player)
 {
     foreach (Vector2 data in _player.path)
     {
         map[(int)data.x, (int)data.y] = 0;
         tilemap[(int)data.x, (int)data.y].GetComponent <NeuralTubeAreaClaim> ().Lose();
     }
     _player.path.Clear();
     _player.tracking = false;
 }
Пример #3
0
 /*
  * When an enemy runs into a player's claim path,
  * the content of the path should be removed
  */
 void UnClaim(NeuralTubePlayer _player)
 {
     foreach(Vector2 data in _player.path)
     {
         map[(int)data.x,(int)data.y] = 0;
         tilemap[(int)data.x,(int)data.y].GetComponent<NeuralTubeAreaClaim> ().Lose();
     }
     _player.path.Clear ();
     _player.tracking = false;
 }
Пример #4
0
    /*
     *
     *
     */
    void Claimed(NeuralTubePlayer _player)
    {
        Vector2 start = (Vector2)_player.path [0];
        Vector2 end = (Vector2)_player.path [_player.path.Count-1];

        if (map [(int)start.x, (int)start.y-1] == 0 && map [(int)start.x, (int)start.y+1] == 0) {
            ArrayList down = AvailableCount(new Vector2(start.x, start.y-1), new Vector2(0,-1));
            ArrayList top = AvailableCount(new Vector2(start.x, start.y+1), new Vector2(0,1));
            if (down.Count < top.Count) {
                foreach (Vector2 data in down) {
                    map[(int)data.x,(int)data.y] = 7;
                    tilemap[(int)data.x, (int)data.y].GetComponent<NeuralTubeAreaClaim> ().Own();
                }
            }
            else {
                foreach (Vector2 data in top) {
                    map[(int)data.x,(int)data.y] = 7;
                    tilemap[(int)data.x, (int)data.y].GetComponent<NeuralTubeAreaClaim> ().Own();
                }
            }
        } else
        if (map [(int)start.x-1, (int)start.y] == 0 && map [(int)start.x+1, (int)start.y] == 0) {
            ArrayList left = AvailableCount(new Vector2(start.x-1, start.y), new Vector2(-1,0));
            ArrayList right = AvailableCount(new Vector2(start.x+1, start.y), new Vector2(1,0));
            if (right.Count < left.Count) {
                foreach (Vector2 data in right) {
                    map[(int)data.x,(int)data.y] = 7;
                    tilemap[(int)data.x, (int)data.y].GetComponent<NeuralTubeAreaClaim> ().Own();
                }
            }
            else {
                foreach (Vector2 data in left) {
                    map[(int)data.x,(int)data.y] = 7;
                    tilemap[(int)data.x, (int)data.y].GetComponent<NeuralTubeAreaClaim> ().Own();
                }
            }
        }

        foreach(Vector2 data in _player.path)
        {
            map[(int)data.x,(int)data.y] = 7;
            tilemap[(int)data.x, (int)data.y].GetComponent<NeuralTubeAreaClaim> ().Own();
        }
        _player.path.Clear ();

        int count = 0;
        for (int i = map.GetLowerBound(1); i <= map.GetUpperBound(1); ++i) {
            for (int j = map.GetLowerBound(0); j <= map.GetUpperBound(0); ++j) {
                if (map [j, i] == 0) {
                    count++;
                }
            }
        }
        if (count == 0) {
            GameObject.Find("SaveState").GetComponent<SaveState>().SaveVariable(GameObject.Find("SaveState").GetComponent<SaveState>().loaded_data.lvl+1,0,"");
            Application.LoadLevel(2);
        }
    }
Пример #5
0
    /*
     *
     *
     */
    void Claimed(NeuralTubePlayer _player)
    {
        Vector2 start = (Vector2)_player.path [0];
        Vector2 end   = (Vector2)_player.path [_player.path.Count - 1];

        if (map [(int)start.x, (int)start.y - 1] == 0 && map [(int)start.x, (int)start.y + 1] == 0)
        {
            ArrayList down = AvailableCount(new Vector2(start.x, start.y - 1), new Vector2(0, -1));
            ArrayList top  = AvailableCount(new Vector2(start.x, start.y + 1), new Vector2(0, 1));
            if (down.Count < top.Count)
            {
                foreach (Vector2 data in down)
                {
                    map[(int)data.x, (int)data.y] = 7;
                    tilemap[(int)data.x, (int)data.y].GetComponent <NeuralTubeAreaClaim> ().Own();
                }
            }
            else
            {
                foreach (Vector2 data in top)
                {
                    map[(int)data.x, (int)data.y] = 7;
                    tilemap[(int)data.x, (int)data.y].GetComponent <NeuralTubeAreaClaim> ().Own();
                }
            }
        }
        else
        if (map [(int)start.x - 1, (int)start.y] == 0 && map [(int)start.x + 1, (int)start.y] == 0)
        {
            ArrayList left  = AvailableCount(new Vector2(start.x - 1, start.y), new Vector2(-1, 0));
            ArrayList right = AvailableCount(new Vector2(start.x + 1, start.y), new Vector2(1, 0));
            if (right.Count < left.Count)
            {
                foreach (Vector2 data in right)
                {
                    map[(int)data.x, (int)data.y] = 7;
                    tilemap[(int)data.x, (int)data.y].GetComponent <NeuralTubeAreaClaim> ().Own();
                }
            }
            else
            {
                foreach (Vector2 data in left)
                {
                    map[(int)data.x, (int)data.y] = 7;
                    tilemap[(int)data.x, (int)data.y].GetComponent <NeuralTubeAreaClaim> ().Own();
                }
            }
        }

        foreach (Vector2 data in _player.path)
        {
            map[(int)data.x, (int)data.y] = 7;
            tilemap[(int)data.x, (int)data.y].GetComponent <NeuralTubeAreaClaim> ().Own();
        }
        _player.path.Clear();

        int count = 0;

        for (int i = map.GetLowerBound(1); i <= map.GetUpperBound(1); ++i)
        {
            for (int j = map.GetLowerBound(0); j <= map.GetUpperBound(0); ++j)
            {
                if (map [j, i] == 0)
                {
                    count++;
                }
            }
        }
        if (count == 0)
        {
            GameObject.Find("SaveState").GetComponent <SaveState>().SaveVariable(GameObject.Find("SaveState").GetComponent <SaveState>().loaded_data.lvl + 1, 0, "");
            Application.LoadLevel(2);
        }
    }