示例#1
0
        public override bool OnCollision(Fixture f1, Fixture f2, FarseerPhysics.Dynamics.Contacts.Contact contact)
        {
            CollidingSprite other = SyncedGameCollection.GetCollisionComponent(f2);

            if (other != null)
            {
                if (other.Tag == TagCategories.CRYSTAL)
                {
                    Grabbable g_other = (Grabbable)other;
                    if (g_other.HasOwner)
                    {
                        if (g_other.Owner.ID == _start.ID || g_other.Owner.ID == _end.ID)
                        {
                            return(false);
                        }
                        else
                        {
                            g_other.ForcedRelease();
                            return(true);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            return(true);
        }
示例#2
0
        public GameScreen(Game game, List <Library.Character.Name> playerinfo) // TODO: tmp added world to parameters, might solve in a different way later.
            : base(game)
        {
            SyncedGameCollection.InitializeSyncedGameCollection(game);
            world = new World(Vector2.Zero);

            GameComponents.Add(SyncedGameCollection.Instance);

            _map = new Map(Library.Map.Path[Library.Map.Name.Paper], game, world);
            GameComponents.Add(_map);

            Rectangle[] rectangles = new Rectangle[] { new Rectangle(140, 20, 40, 40), new Rectangle(1700, 20, 40, 40), new Rectangle(140, 1020, 40, 40), new Rectangle(1700, 1020, 40, 40) };
            // Controls
            for (int i = 0; i < playerinfo.Count; i++)
            {
                GameComponents.Add(new ScoreLabel((PlayerIndex)i, rectangles[i], Game));
            }
            // Audio
            Library.Audio.PlaySong(Library.Audio.Songs.GameSong3);

            _map.LoadMap(game, playerinfo); // send in player information

            foreach (var ob in SyncedGameCollection.ComponentCollection)
            {
                if (ob is Goal)
                {
                    (ob as Goal).Scored += GameScreen_Scored;
                }
            }
        }
示例#3
0
        public override bool OnCollision(Fixture f1, Fixture f2, Contact contact)
        {
            CollidingSprite other = SyncedGameCollection.GetCollisionComponent(f2);

            if (other.Tag == TagCategories.CRYSTAL)
            {
                if (Item == null)
                {
                    Crystal crystal = other as Crystal;
                    Item = crystal.PickUp(this, _teamColor);
                }
                return(false);
            }
            else if (other.Tag == TagCategories.UNIT)
            {
                return(false);
            }
            else if (other.Tag == TagCategories.COMPACTZONE)
            {
                if (Item == null)
                {
                    CompactZone compactzone = other as CompactZone;
                    Item = compactzone.PickUp(this, _teamColor);
                }
            }
            else if (other.Tag == TagCategories.BARRIER)
            {
                return(false);
            }

            return(true);
        }
示例#4
0
        public override bool OnCollision(Fixture f1, Fixture f2, Contact contact)
        {
            CollidingSprite other = SyncedGameCollection.GetCollisionComponent(f2);

            if (other.Tag == TagCategories.UNIT)
            {
                return(false);
            }

            return(true);
        }
示例#5
0
        public override bool OnCollision(Fixture f1, Fixture f2, FarseerPhysics.Dynamics.Contacts.Contact contact)
        {
            CollidingSprite other = SyncedGameCollection.GetCollisionComponent(f2);

            if (other != null)
            {
                if (other.Tag == TagCategories.UNIT)
                {
                    Color = Color.Magenta;
                    return(false);
                }
            }
            return(false);
        }
示例#6
0
        public override bool OnCollision(Fixture f1, Fixture f2, FarseerPhysics.Dynamics.Contacts.Contact contact)
        {
            CollidingSprite other = SyncedGameCollection.GetCollisionComponent(f2);

            if (other != null)
            {
                if (other is IVictim)
                {
                    if (!_victims.Contains((IVictim)other))
                    {
                        _victims.Add((IVictim)other);
                    }
                }
            }
            return(false);
        }
示例#7
0
        public bool OnCollision(Fixture f1, Fixture f2, Contact contact)
        {
            CollidingSprite crystal = SyncedGameCollection.GetCollisionComponent(f2);

            if (crystal.Tag == TagCategories.CRYSTAL)
            {
                if (Scored != null)
                {
                    PlayerIndex p = (crystal as Crystal).GetPlayerIndex();
                    if ((int)p != -1)
                    {
                        Scored(p);
                        Library.Audio.PlaySoundEffect(Library.Audio.SoundEffects.Score);
                    }
                }
                return(false);
            }
            return(true);
        }
示例#8
0
        public override bool OnCollision(Fixture f1, Fixture f2, FarseerPhysics.Dynamics.Contacts.Contact contact)
        {
            CollidingSprite other = SyncedGameCollection.GetCollisionComponent(f2);

            if (other != null)
            {
                if (other is IVictim)
                {
                    if (!_victims.Contains((IVictim)other))
                    {
                        if (other is Unit)
                        {
                            if (_evilCrystalList.Count + _evilUnitList.Count > _maximumBunshin && _evilUnitList.Count > 0)
                            {
                                world.RemoveBody(_evilUnitList[0].RigidBody);
                                SyncedGameCollection.ComponentCollection.Remove(_evilUnitList[0]);
                                _evilUnitList.RemoveAt(0);
                            }
                            CreateVictimBunshin((IVictim)other);
                            _victims.Add((IVictim)other);
                        }
                        else if (other is Crystal)
                        {
                            if (_evilCrystalList.Count + _evilUnitList.Count > _maximumBunshin && _evilCrystalList.Count > 0)
                            {
                                world.RemoveBody(_evilCrystalList[0].RigidBody);
                                SyncedGameCollection.ComponentCollection.Remove(_evilCrystalList[0]);
                                _evilCrystalList.RemoveAt(0);
                            }
                            CreateVictimBunshin((IVictim)other);
                            _victims.Add((IVictim)other);
                        }
                    }
                }
            }
            return(false);
        }