示例#1
0
 public void DestroyCell(Cell c)
 {
     Collider.Instance.remove(c);
       GameScene.Instance.RemoveChild(c.sprite,true);
       cells.Remove(c);
       //c.sprite.TextureInfo.Dispose();
 }
示例#2
0
 public Boolean checkCellWin(Cell c)
 {
     Sequence seq;
       if (c.type == goalMutation){
     //Support.SoundSystem.Instance.Play("blip.wav");
     goalSprite.Visible = false;
     var right = Support.TiledSpriteFromFile("/Application/assets/display_GOOD.png", 1, 1);
     GameScene.Instance.AddChild(right);
     right.CenterSprite();
     right.Quad.S = right.TextureInfo.TextureSizef/2;
     right.Position = goalSprite.Position;
     right.VertexZ = 1;
     seq = new Sequence();
     seq.Add(new DelayTime(2));
     seq.Add(new CallFunc(() => { GameScene.Instance.RemoveChild(right, true); goalSprite.Visible = true;}));
     GameScene.Instance.RunAction(seq);
     return true;
       }
       //Support.SoundSystem.Instance.Play("blip.wav");
       goalSprite.Visible = false;
       var wrong = Support.TiledSpriteFromFile("/Application/assets/display_BAD.png", 1, 1);
       wrong.CenterSprite();
       wrong.Quad.S = wrong.TextureInfo.TextureSizef/2;
       wrong.Position = goalSprite.Position;
       wrong.VertexZ = 1;
       GameScene.Instance.AddChild(wrong);
       seq = new Sequence();
       seq.Add(new DelayTime(2));
       seq.Add(new CallFunc(() => { GameScene.Instance.RemoveChild(wrong, true); goalSprite.Visible = true;;}));
       GameScene.Instance.RunAction(seq);
       return false;
 }
示例#3
0
        public void SpawnCell(Vector2 pos, int type)
        {
            Cell sprite = new Cell(pos, type);
              GameScene.Instance.AddChild(sprite.sprite);

              Collider.Instance.add(sprite);
              cells.Add(sprite);
        }
示例#4
0
 public void RainSpawn(Cell c, List<GameEntity> nearby)
 {
     if (c.shouldSpawn(nearby) && cells.Count < limit){
     List<int> offspringTypes = c.OffspringTypes(nearby);
     int typeCounter = 0;
     for(int i = 0; i < c.newOffspringCount(nearby); i++){
       if(offspringTypes.Count == 0) break;
       SpawnCell(new Vector2 (c.sprite.Position.X+rng.Next(-20,20), c.sprite.Position.Y+rng.Next(-20,20)), offspringTypes[typeCounter]);
       if(typeCounter < offspringTypes.Count - 1){
     typeCounter++;
       } else{
     typeCounter = 0;
       }
     }
     c.hasReproduced = true;
       }
 }
示例#5
0
 public void NotRainingUpdate(Cell c, List<GameEntity> nearby)
 {
     if(c.watered){
     Console.WriteLine("not raining update");
     if(!c.hasReproduced){
       for(int j = 0; j < nearby.Count; j++){
     Cell e = (Cell)nearby[j];
     if(e.watered){
       Console.WriteLine("watered " + c.type);
       List<int> offspringTypes = c.OffspringTypes(nearby);
       if(offspringTypes.Count == 0) break;
       SpawnCell(new Vector2 (c.sprite.Position.X+rng.Next(-20,20), c.sprite.Position.Y+rng.Next(-20,20)), offspringTypes[0]);
       c.hasReproduced = true;
       c.watered = false;
       break;
     }
       }
     } else {
       //Console.WriteLine("has birthd babby");
     }
       }
 }
示例#6
0
 public override void CollideTo(GameEntity instance)
 {
     Boolean canGrab = (instance == grabbing || grabbing == null);
       if(Input2.GamePad0.Circle.Down && canGrab){
     if(instance is Cell){
       Cell c = (Cell)instance;
       //c.sprite.Position = new Vector2(c.sprite.Position.X+10, c.sprite.Position.Y+10);
       c.grabbed = true;
       grabbing = c;
       }
       } else {
     if(!(instance is Cell)) return;
     Cell c = (Cell)instance;
     //instance.sprite.Position += (instance.sprite.Position-sprite.Position)*.2f;
     Vector2 cellCenter = c.GetCenter();
     Vector2 playerCenter = this.GetCenter();
     Vector2 displacement = cellCenter - playerCenter;
     if(System.Math.Abs(displacement.X) > System.Math.Abs(displacement.Y)){
       if(playerCenter.X < cellCenter.X){
     sprite.Position = new Vector2(sprite.Position.X - runSpeed,sprite.Position.Y);
       } else if(playerCenter.X > cellCenter.X){
     sprite.Position = new Vector2(sprite.Position.X + runSpeed,sprite.Position.Y);
       }
     } else {
       if(playerCenter.Y < cellCenter.Y){
     sprite.Position = new Vector2(sprite.Position.X,sprite.Position.Y - runSpeed);
       } else if(playerCenter.Y > cellCenter.Y){
     sprite.Position = new Vector2(sprite.Position.X,sprite.Position.Y + runSpeed);
       }
     }
       }
 }
示例#7
0
        public override void Tick(float dt)
        {
            base.Tick(dt);
              walking = false;
              Vector2 delta = Vector2.Zero;

              if(Input2.GamePad0.Right.Down){
            walking = true;
            walkright = true;
            if(walkDirection != WalkDirs.WLK_RIGHT){
              sprite.StopAllActions();
              sprite.RunAction(WalkRightAnimation);

            }
            walkDirection |= WalkDirs.WLK_RIGHT;
            delta = new Vector2(runSpeed,0);
              } else if(Input2.GamePad0.Left.Down){
            walking = true;
            walkleft = true;
            if(walkDirection != WalkDirs.WLK_LEFT){
              sprite.StopAllActions();
              sprite.RunAction(WalkLeftAnimation);

            }
            walkDirection |= WalkDirs.WLK_LEFT;
            delta = new Vector2(-runSpeed,0);
              }

              if(Input2.GamePad0.Up.Down){
            walking = true;
            walkup = true;
            if(walkDirection != WalkDirs.WLK_UP){
              sprite.StopAllActions();
              sprite.RunAction(WalkBackAnimation);

            }
            walkDirection |= WalkDirs.WLK_UP;
            delta += new Vector2(0,runSpeed);
              } else if(Input2.GamePad0.Down.Down){
            walking = true;
            walkdown = true;
            if(walkDirection != WalkDirs.WLK_DOWN){
              sprite.StopAllActions();
              sprite.RunAction(WalkFrontAnimation);

            }
            walkDirection |= WalkDirs.WLK_DOWN;
            delta += new Vector2(0,-runSpeed);
              }

              sprite.Position += delta;

              if(Input2.GamePad0.Square.Down){
            Support.SoundSystem.Instance.Play("WaterPlop_2.wav");
            waterClosestPlants();
              }

              if(!walking){
            sprite.StopAllActions();
            walkDirection = WalkDirs.WLK_NONE;
            walknone = true;
              }
              if(grabbing != null){
            carryplant = false;
            grabbing.sprite.Position = new Vector2(sprite.Position.X, sprite.Position.Y+70);
              }
              if(!Input2.GamePad0.Circle.Down && grabbing != null){
            grabbing.grabbed = false;
            grabbing = null;
              }
        }