Ignore:
Timestamp:
2014-07-21 15:11:41 (7 years ago)
Author:
mijoilmo
Message:
 
Location:
2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Player.cs

    r5499 r5524  
    144144                    double deltaY = this.Y - kvpair.Value.Y; 
    145145                    Angle approachAngle = (kvpair.Value.Position - this.Position).Angle; 
    146                     parent.LoadLevel(kvpair.Key, approachAngle); 
     146                    //parent.LoadLevel(kvpair.Key, approachAngle); 
    147147                } 
    148148            } 
  • 2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor.cs

    r5499 r5524  
    2828    private Galaxy galaxy; 
    2929    public Galaxy Galaxy { get { return galaxy; } set { galaxy = value; } } 
    30     private Dictionary<int, Dictionary<int, Dictionary<int, GameObject>>> positionGrid = new Dictionary<int, Dictionary<int, Dictionary<int, GameObject>>>(); 
     30    private Dictionary<int, Dictionary<int, List<GameObject>>> positionGrid = new Dictionary<int, Dictionary<int, List<GameObject>>>(); 
     31    private List<GameObject> addedList = new List<GameObject>(); 
    3132 
    3233    void AssignKeys() 
     
    99100            galaxy.CurrentPlanet = galaxy.Planets[currentLevel.Id];//aseta galaksiin tiedot nykyisestä planeetasta 
    100101            player.Y = Level.Top - Screen.Height; 
    101             player.X = (planetAngle.Degrees / Angle.FullAngle.Degrees) * Level.Width - Level.Width / 2; 
     102            //player.X = (planetAngle.Degrees / Angle.FullAngle.Degrees) * Level.Width - Level.Width / 2; 
    102103            Layers[-3].RelativeTransition = new Vector(1, 1); 
    103104        } 
     
    285286        Predicate<GameObject> predicate = isGameObject; 
    286287        List<GameObject> list = this.GetObjects(predicate); 
    287         foreach (GameObject obj in list) 
    288         { 
    289  
     288        int x = Convert.ToInt32(Math.Round(player.X / 5000) * 5000); 
     289        int y = Convert.ToInt32(Math.Round(player.Y / 5000) * 5000); 
     290        foreach (GameObject obj in addedList)//tuhoa vanhat objektit 
     291        { 
     292            Remove(obj); 
     293        } 
     294        addedList.Clear(); 
     295        foreach (GameObject obj in list)//lisää uudet objektit 
     296        { 
     297            if (!positionGrid.ContainsKey(x)) { continue; } 
     298            if (!positionGrid[x].ContainsKey(y)) { continue; } 
     299            for (var i = 0; i < positionGrid[x][y].Count; i++) 
     300            { 
     301                positionGrid[x][y][i].Layer = new Layer(); 
     302                addedList.Add(positionGrid[x][y][i]); 
     303            } 
    290304        } 
    291305        base.Update(gameTime); 
     
    295309        return (obj is GameObject); 
    296310    } 
    297     private void AddCheap(GameObject o){ 
    298         int x = Convert.ToInt32(o.X), y = Convert.ToInt32(o.Y); 
     311    private void AddCheap(GameObject o) 
     312    { 
     313        int x = Convert.ToInt32(Math.Round(o.X / 5000) * 5000), 
     314            y = Convert.ToInt32(Math.Round(o.Y / 5000) * 5000); 
    299315        if (!positionGrid.ContainsKey(x)) 
    300316        { 
    301             Dictionary<int, Dictionary<int, GameObject>> posGridX = new Dictionary<int, Dictionary<int, GameObject>>(); 
     317            Dictionary<int, List<GameObject>> posGridX = new Dictionary<int, List<GameObject>>(); 
    302318            positionGrid.Add(x, posGridX); 
    303319        } 
    304320        if (!positionGrid[x].ContainsKey(y)) 
    305321        { 
    306             Dictionary<int, GameObject> posGridY = new Dictionary<int, GameObject>(); 
     322            List<GameObject> posGridY = new List<GameObject>(); 
    307323            positionGrid[x].Add(y, posGridY); 
    308324        } 
    309325        GameObject uusi = ((GameObject)o); 
    310         positionGrid[x][y].Add(positionGrid[x][y].Count - 1, uusi); 
    311         Add(o); 
     326        positionGrid[x][y].Add(uusi); 
     327        Add(uusi); 
     328        Remove(uusi); 
    312329    } 
    313330} 
Note: See TracChangeset for help on using the changeset viewer.