예제 #1
0
        public void remove(batchEnum _enum, GameObject _obj)
        {
            GameObjNode node = findGameObj(_obj);

            if (node != null)
            {
                if (node.prev != null)
                {       // middle or last node
                    node.prev.next = node.next;
                }
                else
                {  // first
                    this.active = node.next;
                }

                if (node.next != null)
                {       // middle node
                    node.next.prev = node.prev;
                }

                addBodyToDestroy(_obj.physicsObj.body);

                if (_obj.spriteRef != null)
                {
                    SBNode SBNode = SpriteBatchManager.Instance().getBatch(_enum);
                    SBNode.removeDisplayObject(_obj.spriteRef);
                }

                if (_obj.physicsObj != null)
                {
                    PhysicsMan.Instance().removePhysicsObj(_obj.physicsObj);
                }
            }
        }
예제 #2
0
        public void removeExplosion(object obj)
        {
            CallBackData nodeData = (CallBackData)obj;

            SBNode sbNode = SpriteBatchManager.Instance().getBatch(batchEnum.explosions);

            sbNode.removeDisplayObject(nodeData.spriteRef);
        }
예제 #3
0
        public void respawn(object obj)
        {
            CallBackData data = (CallBackData)obj;

            Player player = getPlayer(data.playerID);

            if (!player.Alive())
            {
                player.lives--;

                switch (player.lives)
                {
                case 3:
                {
                    SBNode sbNode = SpriteBatchManager.Instance().getBatch(batchEnum.ships);
                    sbNode.removeDisplayObject(player.lifeSprite3);

                    respawnData(data.playerID);
                    player.state = PlayerState.alive;

                    break;
                }

                case 2:
                {
                    SBNode sbNode = SpriteBatchManager.Instance().getBatch(batchEnum.ships);
                    sbNode.removeDisplayObject(player.lifeSprite2);

                    respawnData(data.playerID);
                    player.state = PlayerState.alive;

                    break;
                }

                case 1:
                {
                    SBNode sbNode = SpriteBatchManager.Instance().getBatch(batchEnum.ships);
                    sbNode.removeDisplayObject(player.lifeSprite1);

                    respawnData(data.playerID);
                    player.state = PlayerState.alive;

                    break;
                }


                case 0:
                {
                    if (player.id == PlayerID.one)
                    {
                        ScoreManager.Instance().p2Win();
                    }
                    else
                    {
                        ScoreManager.Instance().p1Win();
                    }


                    Game1.GameInstance.GameOver();
                    break;
                }
                }
                player.state = PlayerState.alive;
            }
        }