// // The only job for this system is to start the game // private void Start() { // // Initialize the card deck // (Trigger InitCardDeckEvent and give number of deck=0) // //EventManager.TriggerEvent("InitCardDeckEvent", "0"); // CardDeckManager.DeckLocation = deckOfCards; //where to stack the deck CardDeckManager.CurrentDeckNumber = 0; //only one deck is allowed (default) CardDeckManager.CurrentCardBack = 8; //red CardDeckManager.DeckFanOutDistance = 0.03f; //fan out value to right for deck CardDeckManager.CreateDeckOfCards(); // // Find where the stacks are by reading an XML file into a datatable // //CardStacks cs = new CardStacks(); // cs.FilePath = new StringReader(StacksLayout.text); CardStacks cs = new CardStacks(new StringReader(StacksLayout.text)); //string temp = Application.streamingAssetsPath; //cs.FilePath = temp.Replace("StreamingAssets", "Resources/" + StacksLayout.name + ".xml"); //cs.Init(); //StackCollection ic = StackCollection.Load("StacksDB"); //foreach (StackItems item in ic.stacks) //{ // print(item.name); //} }
void Handle(string value) { int stack = Convert.ToInt32(value); // // We'll put a card under the stack that is requesting a card // int cardIndex; GameObject stackObj; GameObject cardObj; if (stack == 0) { stackObj = GameObject.Find("PlayerStack"); } else { stackObj = GameObject.Find("DealerStack"); } CardStackComponent cardStack = stackObj.GetComponent <CardStackComponent>(); // // Add a card and sort the list so cards will appear in suit order // cardIndex = CardDeckManager.GetACard(); // // end of deck? // if (cardIndex < 0) { return; } cardStack.cardsInStack.Add(cardIndex); // // To do Descending, first sort Ascending, then reverse the list // cardStack.cardsInStack.Sort(); cardStack.cardsInStack.Reverse(); // // Get the card obj // cardObj = CardDeckManager.GetCardFaceDown(cardIndex); Card cCard = cardObj.GetComponent <Card>(); cCard.cardStack = stack; //this will tell us which stack holds this card cCard.cardFaceShowing = cardStack.faceUp; // // Determine where the card goes on screen // cardObj.transform.parent = stackObj.transform; cardObj.transform.localPosition = new Vector2(stackObj.transform.position.x + .07f, 0); // // trigger display of stack (if any are face up, then they will display) // EventManager.TriggerEvent("DisplayCardStackEvent", stack.ToString()); }
public void OnDestroyed() { MyEnemyPlayer = null; GameManager = null; HandManager = null; CardDeckManager = null; BattleGroundManager = null; }
public void Run() { CardDeckManager carddeck = new CardDeckManager(); carddeck.Initializer(CardList); carddeck.Output(CardList); Console.ReadLine(); }
public BattlePlayer(string username, int clientId, int metalLeft, int metalMax, int lifeLeft, int lifeMax, int energyLeft, int energyMax, GameManager serverGameManager) : base(username, metalLeft, metalMax, lifeLeft, lifeMax, energyLeft, energyMax) { ClientId = clientId; GameManager = serverGameManager; HandManager = new Battle_HandManager(this); CardDeckManager = new CardDeckManager(this); BattleGroundManager = new BattleGroundManager(this); BattleStatistics = new BattleStatistics(); }
void Handle(string value) { int stack = Convert.ToInt32(value); GameObject stackObj; //which stack to work with GameObject cardObj; //current cardface(back) int cnt = 0; //multiplier for offset if (stack == 0) { stackObj = GameObject.Find("PlayerStack"); } else { stackObj = GameObject.Find("DealerStack"); } Transform parentTransform = stackObj.transform; CardStackComponent cStack = stackObj.GetComponent <CardStackComponent>(); // // Loop thru a list of card values (integers) // cnt = cStack.cardsInStack.Count; foreach (int cardIndex in cStack.cardsInStack) { cardObj = GameObject.Find("Card_D0" + "_C" + cardIndex.ToString()); Vector3 temp = parentTransform.position + new Vector3(cnt * cStack.xOffset, cnt * cStack.yOffset); cardObj.transform.position = temp; Card cCard = cardObj.GetComponent <Card>(); // // find what image component to disp for the Entity // SpriteRenderer srender = cardObj.GetComponent <Renderer>() as SpriteRenderer; if (cCard.cardFaceShowing) { srender.sprite = CardDeckManager.GetCardFace(cardIndex); } else { srender.sprite = CardDeckManager.GetCardBack(cardIndex); } // // reverse the order of sprites with 0 being the first card way back // srender.sortingOrder = cnt; cnt -= 1; } }
private CardDeckManager() { if (_instance != null) { throw new CannotHaveTwoInstancesException(); } _instance = this; _allImages = Resources.LoadAll <Sprite>("CardImages"); // // load all the faces for cards 0-51 // instance.cardfaces = new Sprite[52]; for (int i = 0; i < 52; i++) { instance.cardfaces[i] = _allImages[i]; } // // back of cards 52-63 // instance.cardBacks = new Sprite[12]; for (int i = 0; i < 12; i++) { instance.cardBacks[i] = _allImages[i + 52]; } // // Joker is card 64 // instance.cardJokers = new Sprite(); instance.cardJokers = _allImages[64]; instance._currentCardBack = 0; instance._currentCardNumber = 0; instance._currentDeckNumber = 0; _allImages = null; }
public override void Play() { Global.CurrentScene = this; Global.DebugRenderEnabled = false; dispY = (int)Global.WindowCenter.Y - 100; dispX = 40; //znznznznznznznznznznznznznznznznznznznznznznznznznznznznzn // Hand cursor mouse + boxcollider //znznznznznznznznznznznznznznznznznznznznznznznznznznznznzn tmpEnt = this.CreateGameEntity(Vector2.Zero); tmpEnt.Name = "cursor"; textureImage = Raylib.LoadTexture("Assets/Img/hand.png"); Spr = new Sprite(textureImage); Spr.RenderLayer = Global.CURSOR_LAYER; //on top of everything tmpEnt.Add(Spr); BoxCollider bxxx = new BoxCollider(12, 12); tmpEnt.Add(bxxx); tmpEnt.Add <MouseComponent>(); //znznznznznznznznznznznznznznznznznznznznznznznznznznznznzn // Game status (Score + Game over) //znznznznznznznznznznznznznznznznznznznznznznznznznznznznzn GameStatus = this.CreateGameEntity(new Vector2(5, 10)); GameStatus.Name = "Game Status"; Text scoreTxt = new Text("Score: ", TextFontTypes.Arial); GameStatus.Add(scoreTxt); MsgBox mb = new MsgBox(Global.WindowCenter - new Vector2(150, 0), 350, 150, Color.BROWN); mb.Visiable = false; GameStatus.Add(mb); GameStatus.Add <GameStatComponent>(); //znznznznznznznznznznznznznznznznznznznznznznznznznznznznzn // Create a deck of cards //znznznznznznznznznznznznznznznznznznznznznznznznznznznznzn CardDeck = new CardDeckManager(this); CardDeck.CardsHaveCollider = false; CardDeck.CreateDeckOfCards(false); CreateDealPile(); // deal stack (falce down) CreateDrawPile(); // face up dealt one card at a time CreateEmptyAcePiles(); // 4 of them CreateEmptyPlayPiles(); // 7 of them CreateEmptyDragPile(); // used to disp cards being dragged around DealCardsToPiles(); // draw cards & place in piles above // // Play Button // Global.StateOfGame = GameState.Over; PlayBtn = CreateSceneEntity(new Vector2(850, 50)); PlayBtn.Name = "playBtn"; position = PlayBtn.Get <Transform>().Position; Button bt = new Button(position, 75, 30, "Play", -6, 2); PlayBtn.Add(bt); bt.Click += PlayButton; // // End Button // Global.StateOfGame = GameState.Over; entUI = CreateSceneEntity(new Vector2(850, 100)); entUI.Name = "playBtn"; position = entUI.Get <Transform>().Position; bt = new Button(position, 75, 30, "End", -6, 2); entUI.Add(bt); bt.Click += EndButton; //znznznznznznznznznznznznznzn // Scene Starts Playing //znznznznznznznznznznznznznzn }