예제 #1
0
 private void performAttack()
 {
     //start the attack, the update and draw methods will do the rest.
     attacking = true;
     attackingWeaponTexture  = currentPlayer.getTextureForCurrentWeapon();
     attackingWeaponPosition = new Vector2(currentPlayer.getCurrentPos().X + currentPlayer.getTexture().Width - 20, currentPlayer.getCurrentPos().Y + 72);
     attackingWeaponOrigin   = new Vector2(0, attackingWeaponTexture.Height);
     RotationAngle           = 0.0f;
     AttackTimeElapsed       = 0;
     maxAttackTime           = 10;
 }
예제 #2
0
        private void constructItem()
        {
            List <Tuple <resource.resourceTypes, int> > costs = new List <Tuple <resource.resourceTypes, int> >();

            foreach (constructionItem item in items)
            {
                if (item.selected)
                {
                    costs = item.cost;

                    foreach (Tuple <resource.resourceTypes, int> cost in costs)
                    {
                        if (!playerInv.contains(cost.Item1, cost.Item2))
                        {
                            //do nothing
                            return;
                        }
                    }

                    foreach (Tuple <resource.resourceTypes, int> cost in costs)
                    {
                        playerInv.decreaseResource(cost.Item1, cost.Item2);
                    }

                    if (item.appearsInInventory)
                    {
                        playerInv.addToInventory(item.type, 1);
                    }
                    else if (item.appearsOnMap)
                    {
                        Vector2 location = new Vector2();
                        location.X = currPlayer.getCurrentPos().X + currPlayer.getTexture().Width + currMap.getViewport().X;
                        location.Y = currPlayer.getCurrentPos().Y + currPlayer.getTexture().Height + currMap.getViewport().Y;
                        //add spike pits and trees to the world.
                        if (item.type == resource.resourceTypes.Tree)
                        {
                            currMap.addTree(location);
                        }
                        else if (item.type == resource.resourceTypes.SpikePit)
                        {
                            currMap.addTrapToMap(location);
                        }
                    }

                    break;
                }
            }
        }