Пример #1
0
        public void Update(float time, ParticleManager pMan, Character character)
        {
            //Fan stuff
            Vector2 pos = Vector2.Zero;
            foreach (Fan s in fans)
            {
                pos = new Vector2(s.col * (CELL_SIZE * 2) + (CELL_SIZE), s.row * (CELL_SIZE * 2) + (CELL_SIZE));
                s.current += time;
                if (s.current > s.interval)
                {
                    s.current = 0f;
                    pMan.SprayAir(pos, s.Rotation, s.power);
                }

                //Check for collision
                //Broad phase
                float distance = Vector2.Distance(character.position, pos);
                if(distance < 500f)
                {
                    //Check if in area of airflow
                    bool applyForce = false;
                    switch (s.direction)
                    {
                        case Direction.Up:
                            if (character.CollRect.Center.X > pos.X - CELL_SIZE && character.CollRect.Center.X < pos.X + CELL_SIZE &&
                                character.CollRect.Center.Y <= pos.Y)
                            {
                                applyForce = true;
                            }
                            break;
                        case Direction.Down:
                            if (character.CollRect.Center.X > pos.X - CELL_SIZE && character.CollRect.Center.X < pos.X + CELL_SIZE &&
                                character.CollRect.Center.Y <= pos.Y)
                            {
                                applyForce = true;
                            }
                            break;
                        case Direction.Left:
                            if (character.CollRect.Center.Y > pos.Y - CELL_SIZE && character.CollRect.Center.Y < pos.Y + CELL_SIZE &&
                                character.CollRect.Center.X <= pos.X)
                            {
                                applyForce = true;
                            }
                            break;
                        case Direction.Right:
                            if (character.CollRect.Center.Y > pos.Y - CELL_SIZE && character.CollRect.Center.Y < pos.Y + CELL_SIZE &&
                                character.CollRect.Center.X >= pos.X)
                            {
                                applyForce = true;
                            }
                            break;
                        default:
                            break;
                    }
                    if (applyForce)
                    {
                        character.ApplyForce(Utility.AngleFrom(s.Rotation), distance, s.power);
                    }
                }

            }
        }
Пример #2
0
 public void Start()
 {
     level = new Level();
     pMan = new ParticleManager();
     character = new Character();
     currentLevel--;
     NextLevel();
 }