예제 #1
0
        public override void performLowest(int column)
        {
            GameObjectTree temp = activeColumns;

            while (temp != null && temp.getStatus() == Status.Inactive)
            {
                temp = temp.nextNode;
            }
            GameObjectTree check = temp;

            while (temp != null)
            {
                if (temp.getStatus() == Status.Active)
                {
                    if (temp.getPosY() < check.getPosY())
                    {
                        check = temp;
                    }
                }
                temp = temp.nextNode;
            }
            if (check != null)
            {
                check.performLowest(column);
            }
        }
예제 #2
0
        public virtual void removeFromActive(int num)
        {
            GameObjectTree columnTemp     = activeColumns;
            GameObjectTree columnTempPrev = null;

            while (columnTemp != null && columnTemp.getNum() != num)
            {
                columnTempPrev = columnTemp;
                columnTemp     = columnTemp.nextNode;
            }
            if (columnTemp != null)
            {
                if (columnTempPrev == null)
                {
                    activeColumns       = activeColumns.nextNode;
                    columnTemp.nextNode = null;
                }
                else
                {
                    columnTempPrev.nextNode = columnTemp.nextNode;
                    columnTemp.nextNode     = null;
                }
                if (reserveColumns == null)
                {
                    reserveColumns = columnTemp;
                }
                else
                {
                    columnTemp.nextNode = reserveColumns;
                    reserveColumns      = columnTemp;
                }
            }
        }
예제 #3
0
 public override void checkGameObjectTreeCollision(GameObjectTree tree)
 {
     if (tree.getCollisionComponent().checkCollision(tree.getCollisionComponent(), gameObject.getCollisionComponent()))
     {
         gameObject.notifyHit();
     }
 }
예제 #4
0
        public MovementController(GameObjectTree gameTree)
        {
            this.alienTree     = gameTree;
            translationCommand = new CommandAlienTranslation(this, 10, timeOffset);
            animationCommand   = new CommandAnimationAlien(this, 10, timeOffset);

            //Receiver.instance.addCommand(translationCommand);
        }
예제 #5
0
        GameObjectTree makeGameObjectTree()
        {
            SpriteManager  m = SpriteManagerFactory.createSpriteManager(SpriteType.Alien, 0);
            GameObjectTree g = new GameObjectTree();
            Scale          a = SizeFactory.getFactory.alienScale;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 11; j++)
                {
                    GameObject temp = GameObjectFactory.createGameObject();
                    Sprite     s    = ProxySpriteFactory.makeProxySprite(SpriteType.Crab);
                    m.createActive(s);
                    temp.setSprite(s);
                    temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy);
                    temp.setScale(a.spriteWidth, a.spriteHeight);
                    temp.setColScale(a.colWidth, a.colHeight);
                    Alien t = new Alien(temp, ScoreReferenceFactory.getFactory.getScore(SpriteType.Crab));
                    PlayerModeStatusManagerFactory.getFactory.addObject(t);
                    g.AddToActive(j, i, t);
                }
            }
            for (int i = 2; i < 4; i++)
            {
                for (int j = 0; j < 11; j++)
                {
                    GameObject temp = GameObjectFactory.createGameObject();
                    Sprite     s    = ProxySpriteFactory.makeProxySprite(SpriteType.Bug);
                    m.createActive(s);
                    temp.setSprite(s);
                    temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy);
                    temp.setScale(a.spriteWidth, a.spriteHeight);
                    temp.setColScale(a.colWidth, a.colHeight);
                    Alien t = new Alien(temp, ScoreReferenceFactory.getFactory.getScore(SpriteType.Bug));
                    PlayerModeStatusManagerFactory.getFactory.addObject(t);
                    g.AddToActive(j, i, t);
                }
            }
            for (int i = 4; i < 5; i++)
            {
                for (int j = 0; j < 11; j++)
                {
                    GameObject temp = GameObjectFactory.createGameObject();
                    Sprite     s    = ProxySpriteFactory.makeProxySprite(SpriteType.Squid);
                    m.createActive(s);
                    temp.setSprite(s);
                    temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy);
                    temp.setScale(a.spriteWidth, a.spriteHeight);
                    temp.setColScale(a.colWidth, a.colHeight);
                    Alien t = new Alien(temp, ScoreReferenceFactory.getFactory.getScore(SpriteType.Squid));
                    PlayerModeStatusManagerFactory.getFactory.addObject(t);
                    g.AddToActive(j, i, t);
                }
            }
            return(g);
        }
예제 #6
0
        public void checkAlienCollision(GameObjectTree tree)
        {
            SLink temp = head;

            while (temp != null)
            {
                ((ShieldDataNode)temp).getShield().checkGameObjectTreeCollision(tree);
                temp = temp.next;
            }
        }
예제 #7
0
        public override ObjectController acceptGameObjectVisit(CollisionSprite visitor)
        {
            GameObjectTree columnTemp = activeColumns;


            if (this.acceptGridVisit(visitor))
            {
                return(gameObject);
            }
            return(null);
        }
예제 #8
0
        public virtual void setAllActive(Status st)
        {
            this.currentStatus = st;
            collisionComponent.setStatus(st);
            GameObjectTree columnTemp = activeColumns;

            while (columnTemp != null)
            {
                columnTemp.setAllActive(st);
                columnTemp = columnTemp.nextNode;
            }
        }
예제 #9
0
        public override ObjectController acceptGameObjectVisit(CollisionSprite visitor)
        {
            GameObjectTree columnTemp = activeColumns;

            while (columnTemp != null)
            {
                if (columnTemp.acceptGridVisit(visitor))
                {
                    return(columnTemp.acceptGameObjectVisit(visitor));
                }
            }
            return(null);
        }
예제 #10
0
        public virtual void performLowest(int column)
        {
            GameObjectTree temp = activeColumns;

            while (temp.nextNode != null && temp.getNum() != column)
            {
                temp = temp.nextNode;
            }
            if (temp.getStatus() == Status.Active)
            {
                temp.performLowest(column);
            }
        }
예제 #11
0
        public void sendProjectiles(GameObjectTree gameTree)
        {
            DLink temp = pActive;

            while (temp != null)
            {
                if (((ProjectileDataNode)temp).getProjectile().getStatus() == Status.Active)
                {
                    gameTree.checkProjectileCollision(((ProjectileDataNode)temp).getProjectile());
                }
                temp = temp.pNext;
            }
        }
예제 #12
0
        public override void setPos(float x, float y, float xOffset, float yOffset)
        {
            GameObjectTree columnTemp = activeColumns;
            int            i          = 0;

            while (columnTemp != null)
            {
                columnTemp.setPos(x, (y + (columnTemp.getNum() * yOffset)), xOffset, yOffset);
                columnTemp = columnTemp.nextNode;
                i++;
            }
            setCollisionComponent();
        }
예제 #13
0
        public virtual void setCollisionComponent()
        {
            GameObjectTree columnTemp = activeColumns;

            //columnTemp.setCollisionComponent();
            while (columnTemp != null && columnTemp.getStatus() != Status.Active)
            {
                columnTemp = columnTemp.nextNode;
            }
            if (columnTemp != null)
            {
                float smallX = columnTemp.getCollisionComponent().getPosX();
                float largeX = smallX;
                float width  = columnTemp.getCollisionComponent().getWidth();
                float height = columnTemp.getCollisionComponent().getHeight();
                float y      = columnTemp.getCollisionComponent().getPosY();
                columnTemp = columnTemp.nextNode;
                while (columnTemp != null)
                {
                    if (columnTemp.getStatus() == Status.Active)
                    {
                        if (height < columnTemp.getCollisionComponent().getHeight())
                        {
                            height = columnTemp.getCollisionComponent().getHeight();
                            y      = columnTemp.getCollisionComponent().getPosY();
                        }
                        if (largeX < columnTemp.getCollisionComponent().getPosX())
                        {
                            largeX = columnTemp.getCollisionComponent().getPosX();
                        }
                        else if (smallX > columnTemp.getCollisionComponent().getPosX())
                        {
                            smallX = columnTemp.getCollisionComponent().getPosX();
                        }
                        columnTemp.getCollisionComponent();
                    }
                    else
                    {
                        Console.WriteLine("hi Tree");
                    }
                    columnTemp = columnTemp.nextNode;
                }

                collisionComponent.setTransformation(((largeX - smallX) / 2) + smallX, y, (largeX - smallX) + width, height);
            }
            else
            {
                currentStatus = Status.Inactive;
                collisionComponent.setStatus(Status.Inactive);
            }
        }
예제 #14
0
        public override void translate(float xOffset, float yOffset)
        {
            GameObjectTree columnTemp = activeColumns;
            int            i          = 0;

            //collisionComponent.setPosition(collisionComponent.getPosX() + xOffset, collisionComponent.getPosY() + yOffset);
            while (columnTemp != null)
            {
                columnTemp.translate(xOffset, yOffset);
                columnTemp = columnTemp.nextNode;
                i++;
            }
            setCollisionComponent();
        }
예제 #15
0
 public virtual void checkGameObjectTreeCollision(GameObjectTree tree)
 {
     if (tree.getCollisionComponent().checkCollision(this.collisionComponent, tree.getCollisionComponent()))
     {
         GameObjectTree columnTemp = activeColumns;
         while (columnTemp != null)
         {
             if (columnTemp.getStatus() == Status.Active)
             {
                 columnTemp.checkGameObjectTreeCollision(tree);
             }
             columnTemp = columnTemp.nextNode;
         }
     }
 }
예제 #16
0
        public GameObjectTreeFactory()
        {
            alien = makeGameObjectTree();

            SpriteManager m    = SpriteManagerFactory.createSpriteManager(SpriteType.Alien, 0);
            GameObject    temp = GameObjectFactory.createGameObject();
            Sprite        s    = ProxySpriteFactory.makeProxySprite(SpriteType.UFO);
            Scale         a    = SizeFactory.getFactory.alienScale;

            m.createActive(s);
            temp.setSprite(s);
            temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy);
            temp.setScale(a.spriteWidth, a.spriteHeight);
            temp.setColScale(a.colWidth, a.colHeight);
            ufo = new Alien(temp, 0);
            ufo.setStatus(Status.Inactive);
        }
예제 #17
0
        public override void setCollisionComponent()
        {
            GameObjectTree columnTemp = activeColumns;

            while (columnTemp != null && columnTemp.getStatus() != Status.Active)
            {
                columnTemp = columnTemp.nextNode;
            }
            if (columnTemp != null)
            {
                float x      = columnTemp.getCollisionComponent().getPosX();
                float width  = columnTemp.getCollisionComponent().getWidth();
                float height = columnTemp.getCollisionComponent().getHeight();
                float lowY   = columnTemp.getCollisionComponent().getPosY();
                float highY  = columnTemp.getCollisionComponent().getPosY();
                columnTemp = columnTemp.nextNode;
                while (columnTemp != null)
                {
                    if (columnTemp.getStatus() == Status.Active)
                    {
                        if (lowY > columnTemp.getCollisionComponent().getPosY())
                        {
                            lowY = columnTemp.getCollisionComponent().getPosY();
                        }
                        else if (highY < columnTemp.getCollisionComponent().getPosY())
                        {
                            highY = columnTemp.getCollisionComponent().getPosY();
                        }
                        columnTemp.getCollisionComponent();
                    }
                    else
                    {
                        Console.WriteLine("hi");
                    }
                    columnTemp = columnTemp.nextNode;
                }
                collisionComponent.setTransformation(x, ((highY - lowY) / 2) + lowY, width, (highY - lowY) + height);
            }
            else
            {
                collisionComponent.setStatus(Status.Inactive);
                currentStatus = Status.Inactive;
            }
        }
예제 #18
0
 public virtual bool checkProjectileCollision(Projectile projectile)
 {
     if (projectile.getCollisionComponent().checkCollision(this.collisionComponent, projectile.getCollisionComponent()))
     {
         GameObjectTree columnTemp = activeColumns;
         while (columnTemp != null)
         {
             if (columnTemp.getStatus() == Status.Active)
             {
                 if (columnTemp.checkProjectileCollision(projectile))
                 {
                     return(true);
                 }
             }
             columnTemp = columnTemp.nextNode;
         }
     }
     return(false);
 }
예제 #19
0
 public virtual int totalActive()
 {
     if (this.currentStatus == Status.Active)
     {
         int            i          = 0;
         GameObjectTree columnTemp = activeColumns;
         while (columnTemp != null)
         {
             if (columnTemp.getStatus() == Status.Active)
             {
                 i = i + columnTemp.totalActive();
             }
             columnTemp = columnTemp.nextNode;
         }
         return(i);
     }
     else
     {
         return(0);
     }
 }
예제 #20
0
        public override void AddToActive(int column, int row, ObjectController gameObject)
        {
            if (this.activeColumns == null)
            {
                activeColumns = new GameObjectNode(row);
                ((GameObjectNode)activeColumns).setObj(gameObject);
            }
            else
            {
                GameObjectTree columnTemp = activeColumns;
                while (columnTemp.nextNode != null && columnTemp.getNum() != row)
                {
                    columnTemp = columnTemp.nextNode;
                }

                columnTemp.nextNode = new GameObjectNode(row);
                columnTemp          = columnTemp.nextNode;


                ((GameObjectNode)columnTemp).setObj(gameObject);
            }
        }
예제 #21
0
 public virtual void AddToActive(int column, int row, ObjectController gameObject)
 {
     total++;
     if (activeColumns == null)
     {
         activeColumns = new GameObjectColumn(column);
         activeColumns.AddToActive(column, row, gameObject);
     }
     else
     {
         GameObjectTree columnTemp = activeColumns;
         while (columnTemp.nextNode != null && columnTemp.getNum() != column)
         {
             columnTemp = columnTemp.nextNode;
         }
         if (columnTemp.getNum() != column)
         {
             columnTemp.nextNode = new GameObjectColumn(column);
             columnTemp          = columnTemp.nextNode;
         }
         columnTemp.AddToActive(column, row, gameObject);
     }
 }
예제 #22
0
 public virtual bool acceptGameObjectTreeVisit(GameObjectTree gTree)
 {
     return(false);
 }
예제 #23
0
 public ShieldDataNode(GameObjectTree tree, int num)
 {
     this.tree = tree;
     this.num  = num;
 }
 public AlienGridCollisionSubject(GameObjectTree tree, SpriteType name) : base(name)
 {
     this.tree = tree;
 }
예제 #25
0
 public virtual void visit(GameObjectTree tree)
 {
 }
예제 #26
0
        public GameObjectTree makeGameObjectTreeShield()
        {
            SpriteManager  m = SpriteManagerFactory.createSpriteManager(SpriteType.Shield, 0);
            GameObjectTree g = new GameObjectTree();
            Scale          a = SizeFactory.getFactory.shieldScale;

            for (int i = 3; i < 11; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    GameObject temp = GameObjectFactory.createGameObject();
                    Sprite     s    = ProxySpriteFactory.makeProxySprite(SpriteType.Shield);
                    m.createActive(s);
                    temp.setSprite(s);
                    temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy);
                    temp.setScale(a.spriteWidth, a.spriteHeight);
                    temp.setColScale(a.colWidth, a.colHeight);
                    Shield t = new Shield(temp);
                    PlayerModeStatusManagerFactory.getFactory.addObject(t);
                    g.AddToActive(j, i, t);
                }
            }

            for (int j = 0; j < 3; j++)
            {
                GameObject temp = GameObjectFactory.createGameObject();
                Sprite     s    = ProxySpriteFactory.makeProxySprite(SpriteType.Shield);
                m.createActive(s);
                temp.setSprite(s);
                temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy);
                temp.setScale(a.spriteWidth, a.spriteHeight);
                temp.setColScale(a.colWidth, a.colHeight);
                Shield t = new Shield(temp);
                PlayerModeStatusManagerFactory.getFactory.addObject(t);
                g.AddToActive(j, 2, t);
            }
            for (int j = 5; j < 8; j++)
            {
                GameObject temp = GameObjectFactory.createGameObject();
                Sprite     s    = ProxySpriteFactory.makeProxySprite(SpriteType.Shield);
                m.createActive(s);
                temp.setSprite(s);
                temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy);
                temp.setScale(a.spriteWidth, a.spriteHeight);
                temp.setColScale(a.colWidth, a.colHeight);
                Shield t = new Shield(temp);
                PlayerModeStatusManagerFactory.getFactory.addObject(t);
                g.AddToActive(j, 2, t);
            }

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    GameObject temp = GameObjectFactory.createGameObject();
                    Sprite     s    = ProxySpriteFactory.makeProxySprite(SpriteType.Shield);
                    m.createActive(s);
                    temp.setSprite(s);
                    temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy);
                    temp.setScale(a.spriteWidth, a.spriteHeight);
                    temp.setColScale(a.colWidth, a.colHeight);
                    Shield t = new Shield(temp);
                    PlayerModeStatusManagerFactory.getFactory.addObject(t);
                    g.AddToActive(j, i, t);
                }
                for (int j = 6; j < 8; j++)
                {
                    GameObject temp = GameObjectFactory.createGameObject();
                    Sprite     s    = ProxySpriteFactory.makeProxySprite(SpriteType.Shield);
                    m.createActive(s);
                    temp.setSprite(s);
                    temp.setCollisionSprite(ProxySpriteCollisionFactory.proxy);
                    temp.setScale(a.spriteWidth, a.spriteHeight);
                    temp.setColScale(a.colWidth, a.colHeight);
                    Shield t = new Shield(temp);
                    PlayerModeStatusManagerFactory.getFactory.addObject(t);
                    g.AddToActive(j, i, t);
                }
            }
            return(g);
        }