// Use this for initialization void Start() { crown = Crown.Instance; gameMaster = GameMaster.Instance; gameMaster.onGameStarts += OnGameStarts; crown.onPowerCardStateChanges += UpdatePowerCardInteractivity; gameMaster.onTurnEnds += UpdatePowerCardInteractivity; gameMaster.simpleOnGameStateChanges += UpdatePowerCardInteractivity; UpdatePowerCardInteractivity(); }
/* * Login to server and get user main data */ public IEnumerator GetItems(CrownCallbackJSON callback = null) { JSON parameters = new JSON(); parameters.AddField("var1", "teeeeeest55555"); yield return(StartCoroutine(Crown.Request("getPlayerItems", parameters, callback, OnGetItems))); }
public void DropRandomCrown() { if (crowns.Count > 0) { // Drops a random crown and removes it from the crowns list int droppedCrownIndex = Random.Range(0, crowns.Count); Crown droppedCrown = crowns[droppedCrownIndex]; crowns.Remove(droppedCrown); droppedCrown.Drop(Vector2.up * 10.0f); // Equips the player another crown if there is any if (droppedCrown == equippedCrown) { if (crowns.Count > 0) { equippedCrown = crowns[0]; equippedCrownIndex = 0; } else { equippedCrown = null; } } } onCrownDrop.Invoke(); }
void generateCrowns() { var CrownList = gameObject.GetComponentsInChildren <Crown>(); // Debug.Log(CrownList.Length); int spawnerIndex = (int)Random.Range(0.0f, (float)CrownList.Length); // Debug.Log(spawnerIndex); int i = 0; foreach (var Crown in CrownList) { // Find sprite to use and renderer to us it int crownIndex = ((int)Random.Range(0.0f, 100.0f)) % allCrownSprites.Count; var crownSpriteRenderer = Crown.GetComponentInChildren <SpriteRenderer>(); // Allocate sprite and color crownSpriteRenderer.sprite = allCrownSprites[crownIndex]; crownSpriteRenderer.color = new Color(0.0f, Random.Range(0.5f, 1.0f), 0.0f); // Check if crown is spawner if (i == spawnerIndex) { crownWithSpawner = Crown.gameObject; gameObject.GetComponent <Spawning>().setSpawningObject(crownWithSpawner); // spawnRope(); } i++; } }
void OnGUI() { if (!display) { return; } // Display window wnd = GUILayout.Window(-1, wnd, WndDisplay, "CrownEngine Console"); // Keyboard control if (Event.current.type == EventType.KeyUp) { // On TextField focus if (GUI.GetNameOfFocusedControl() == "TextField") { // Execute on Enter if (Event.current.keyCode == KeyCode.Return && wndTextField != "") { Crown.Exec(wndTextField); lastText.Add(wndTextField); lastTextId = lastText.Count; wndTextField = ""; } // List input story on up and down arrows if (lastText.Count > 0) { // Previues text on up arrow if (Event.current.keyCode == KeyCode.UpArrow) { if (lastTextId > 0) { lastTextId--; } wndTextField = lastText[lastTextId] as string; } // Next text on down arrow else if (Event.current.keyCode == KeyCode.DownArrow) { if (lastTextId < lastText.Count - 1) { lastTextId++; wndTextField = lastText[lastTextId] as string; } else { wndTextField = ""; } } } } // Hide console on Escape button if (Event.current.keyCode == KeyCode.Escape) { display = false; } } }
public static IEnumerator RegisterByName(string name, string password, CrownCallbackJSON callback = null) { JSON parameters = new JSON(); parameters.AddField("name", name); parameters.AddField("password", password); yield return(instance.StartCoroutine(Crown.Request("registerByName", parameters, callback, OnLoginByName))); }
// Callback static void OnGetItems(JSON result) { try { Crown.print(result.str); } catch { } }
private void Start() { player = GameObject.FindObjectOfType <Player>(); crown = GameObject.FindObjectOfType <Crown>(); admob = GameObject.FindObjectOfType <Admob>(); playerObject = GameObject.FindGameObjectWithTag("Player"); StartCoroutine(CheckInternetConnection()); }
private void DropCrown() { GameObject crownGO = Instantiate(crownPrefab, transform.position, Quaternion.identity); Crown crown = crownGO.GetComponent <Crown>(); Vector2 crownDirection = new Vector2(Random.Range(-1.0f, 1.0f) * crownDropSpeed, crownDropSpeed); crown.AddKnockbackForce(crownDirection); }
public void AddCrown(Crown crown) { crowns.Add(crown); if (!equippedCrown) { equippedCrown = crown; } onCrownPick.Invoke(); }
private void OnTriggerStay2D(Collider2D collision) { Crown crown = collision.GetComponent <Crown>(); if (crown) { if (player.inputDevice.GetControl(PlayerActions.INTERACT).WasPressed) { crown.Pick(gameObject); } } }
// Callback static void OnLoginByName(JSON result) { try { Crown.instance.userId = result.GetField("userId").str; Crown.instance.userKey = result.GetField("userKey").str; Crown.instance.userSpot = result.GetField("spot").str; } catch { Crown.Error("Login error, data not found"); } }
private void SetPlayer(PlayerIndex playerIndex, Crown crown) { if (GamePad.GetCapabilities(playerIndex).IsConnected) { var player = new Player(Vector2.Zero); player.PlayerIndex = playerIndex; player.TheColor = ColorUtils.ConvertColor(ColorUtils.GetPlayerColor(playerIndex)); player.Crown = crown; crown.TheColor = player.TheColor; GameEnvironment.CurrentPlayers.Add(player); GameDevGame.Current.Components.Add(player); } else { crown.TheColor = new Color(50, 50, 50, 10); crown.StopRotation(); } }
public override bool DropCollectedItem() { if (!IsDead) { return(false); } var topCell = this.Cell.GetTheNeighbouringCell(NeighbouringCell.Top); var bottomCell = this.Cell.GetTheNeighbouringCell(NeighbouringCell.Bottom); var cell = topCell.IsCellFree() ? topCell : bottomCell; var crown = new Crown(cell); cell.Actor = crown; return(true); }
// Update is called once per frame void WndDisplay(int wndId) { // Display log wndTextScroll = GUILayout.BeginScrollView(wndTextScroll); GUI.SetNextControlName("TextArea"); GUILayout.TextArea(Crown.GetLog(), GUILayout.ExpandHeight(true)); // Auto scroll if text area is not focused if (GUI.GetNameOfFocusedControl() != "TextArea") { GUI.ScrollTo(new Rect(0, 50000, 0, 0)); } GUILayout.EndScrollView(); // Display input box GUI.SetNextControlName("TextField"); wndTextField = GUILayout.TextField(wndTextField, 5000); GUI.DragWindow(); }
public Mushroom(Vector3 crownOffset) { gameObject.name = "tree"; float x = Random.Range(-3.0f, 3.0f); float y = Random.Range(5.0f, 20.0f); float z = Random.Range(-3.0f, 3.0f); Vector3 crownPos = new Vector3(x, y, z) + crownOffset * Random.Range(0.0f, 1.0f); Crown tc = new Crown(8, 4, crownPos); tc.transform.SetParent(transform); float d = Random.Range(0.5f, 1.0f); Trunk tt = new Trunk(crownPos, d); tt.transform.SetParent(transform); }
// Use this for initialization void Awake() { Instance = this; powerCardFeedback.SetActive(false); }
void CheckAndSetup() { m_Crowns.ForEach(acrown => { GameDevGame.Current.Components.Remove(acrown); Components.Remove(acrown); }); m_Crowns.Clear(); m_texts.ForEach(text => { GameDevGame.Current.Components.Remove(text); Components.Remove(text); }); m_texts.Clear(); if (GameEnvironment.CurrentPlayers != null) { GameEnvironment.CurrentPlayers.ForEach(player => GameDevGame.Current.Components.Remove(player)); GameEnvironment.CurrentPlayers.Clear(); } int textX = 110; int crownX = 15; int crownY = 20; int textY = crownY + 65; GameEnvironment.CurrentPlayers = new List <Player>(); Crown crown = new Crown(); m_Crowns.Add(crown); SetPlayer(PlayerIndex.One, crown); crown = new Crown(); m_Crowns.Add(crown); SetPlayer(PlayerIndex.Two, crown); crown = new Crown(); m_Crowns.Add(crown); SetPlayer(PlayerIndex.Three, crown); crown = new Crown(); m_Crowns.Add(crown); SetPlayer(PlayerIndex.Four, crown); m_texts.Add(new SimpleText(GetText("P1", PlayerIndex.One), new Vector2(textX, textY), GameEnvironment.FastelavnsFont, Color.White, true)); textX += Spacing; m_texts.Add(new SimpleText(GetText("P2", PlayerIndex.Two), new Vector2(textX, textY), GameEnvironment.FastelavnsFont, Color.White, true)); textX += Spacing; m_texts.Add(new SimpleText(GetText("P3", PlayerIndex.Three), new Vector2(textX, textY), GameEnvironment.FastelavnsFont, Color.White, true)); textX += Spacing; m_texts.Add(new SimpleText(GetText("P4", PlayerIndex.Four), new Vector2(textX, textY), GameEnvironment.FastelavnsFont, Color.White, true)); foreach (Crown acrown in m_Crowns) { acrown.Position = new Vector2(crownX, crownY); crownX += Spacing; crown.Visible = false; } int clubYPos = 10; GameEnvironment.CurrentPlayers.ForEach(p => { if (p.Club == null) { p.Club = new Club(new Vector2(250, clubYPos += 85), Color.SandyBrown); } });// p.TheColor)); }
// Constructor public void Awake() { instance = this; }
/* * Network request (send data and get result) */ public static IEnumerator Request(string function, JSON parameters = null, CrownCallbackJSON callback = null, CrownCallbackJSON internalCallback = null) { string url = instance.serverURL; Crown.Log("Server request " + function); // Create www post WWWForm form = new WWWForm(); // Add platform, function and parameters form.AddField("function", function); form.AddField("parameters", parameters.print()); // Add user data form.AddField("userId", instance.userId); form.AddField("userKey", instance.userKey); form.AddField("userSpot", instance.userSpot); // Download WWW www = new WWW(url, form); yield return(www); // Get request if (www.error == null) { // Try to get JSON DATA JSON result = null; try { result = new JSON(www.text); Crown.Log("Request result: " + result.print()); } catch { Crown.Error("Server wrong data: " + www.text); } // Check for server errors if (result["error"] != null) { Crown.Error("Server error: " + result["error"], true); } // Get json array else if (result["data"] != null) { if (callback != null) { callback(result["data"]); } if (internalCallback != null) { internalCallback(result["data"]); } } else { Crown.Error("Server return's null result", true); } } else { Crown.Error("Request error " + url + ", www error: " + www.error, true); } }
/* * This draw function draws every object and player in the game. It also draws * the level background and the countdown timer. */ public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Vector2 worldOffset) { // Draw the leve wallpaper. spriteBatch.Draw(backgroundTex, new Rectangle(0, 0, 1280, 720), Color.White); // Dispatch the draw event to all game objects: foreach (Object obj in objects) obj.Draw(gameTime, spriteBatch); foreach (Items item in items) item.Draw(gameTime, spriteBatch); foreach (AnimPlayer somePlayer in animPlayers) { if (somePlayer != null) { somePlayer.Draw(gameTime, spriteBatch); } } Crown[] crownArr = new Crown[4]; int temp; bool isSorted = false; for (int i = 0; i < playerTotal; i++) { crownArr[i].index = animPlayers[i].playerKills; crownArr[i].inUse = false; } while (!isSorted) { isSorted = true; for (int i = 0; i < crownArr.Length - 1; i++) { if (crownArr[i].index > crownArr[i + 1].index) { temp = crownArr[i + 1].index; crownArr[i + 1].index = crownArr[i].index; crownArr[i].index = temp; isSorted = false; } } } for (int i = 0; i < playerTotal; i++) { if (crownArr[3].index == animPlayers[i].playerKills && crownArr[3].inUse == false) { crownpos[3] = getCrownPos(animPlayers[i]); crownrot[3] = animPlayers[i].getBaseRotation(); crownArr[3].inUse = true; } else if (crownArr[2].index == animPlayers[i].playerKills && crownArr[2].inUse == false) { crownpos[2] = getCrownPos(animPlayers[i]); crownrot[2] = animPlayers[i].getBaseRotation(); crownArr[2].inUse = true; } else if (crownArr[1].index == animPlayers[i].playerKills && crownArr[1].inUse == false) { crownpos[1] = getCrownPos(animPlayers[i]); crownrot[1] = animPlayers[i].getBaseRotation(); crownArr[1].inUse = true; } else if (crownArr[0].index == animPlayers[i].playerKills && crownArr[0].inUse == false) { crownpos[0] = getCrownPos(animPlayers[i]); crownrot[0] = animPlayers[i].getBaseRotation(); crownArr[0].inUse = true; } } for (int i = 0; i < crowntex.Length; i++) //spriteBatch.DrawString(countDownFont, i.ToString(), new Vector2(crownpos[i].X, crownpos[i].Y), Color.White); spriteBatch.Draw(crowntex[i], crownpos[i], null, Color.White, crownrot[i], new Vector2(crowntex[i].Width/2, crowntex[i].Height/2), SpriteEffects.None, 0); // Alternatively we could draw a in-game menu here. // Draw the game countdown clock: if(currentTime/60 < 9999) if (currentTime < timeLimit) { // Show an actual countdown: spriteBatch.DrawString(levelTimer, "" + (int)(currentTime / 60), new Vector2(1170, 0), Color.White); } else { // The game is still in its countdown "Grace" zone, hence the time limit is shown rather than the actual count. spriteBatch.DrawString(levelTimer, "" + (int)(timeLimit / 60), new Vector2(1170, 0), Color.White); } // The game has been paused, thus draw some fancy pausescreen overlay. if (levelState == LevelStates.Pause) { spriteBatch.Draw(pauzeScreenOverlay, new Rectangle(0, 0, 1280, 720), Color.White); } else if (levelState == LevelStates.StartCountdown) { string countDownString = ".. " + countText + " .."; if (countText == 0) countDownString = ".. FIGHT .."; int countDownFontSize = (int)countDownFont.MeasureString(countDownString).X; spriteBatch.DrawString(countDownFont, countDownString, new Vector2(Game1.INSTANCE.GraphicsDevice.Viewport.Width / 2 - countDownFontSize / 2, 300), Color.White); } }
private void Start() { crown = GameObject.FindObjectOfType <Crown>(); admob = GameObject.FindObjectOfType <Admob>(); }
public override void PickCrown(Crown crown, Line line) { }
public abstract void PickDiamond(Diamond diamond, Line line); // who pick diamond public abstract void PickCrown(Crown crown, Line line);
public GameScreen(Game g) { this.game = g; Size = new Size(1000, 1000); /*Temporary untill graphics are complete */ TextBox txt = new TextBox(); txt.Location = new Point(0, 500); txt.Size = new Size(500, 500); txt.Text = game.getMapDesc(); Controls.Add(txt); /*Whose Turn is displayed */ TextBox whos = new TextBox(); whos.Location = new Point(0, 0); whos.Size = new Size(75, 75); whos.Text = "It is player: " + game.turn " Turn"; Controls.Add(whos); /*Player Followers */ TextBox inven = new TextBox(); inven.Location = new Point(0, 250); inven.Size = new Size(50, 50); inven.Text = "Player " + game.turn + " has " + game.getCurrentPlayerDesc(); Controls.Add(inven); /*Controls*/ /*Skip Button*/ int y = 250; Button skip = new Button(); skip.Location = new Point(y, 1); skip.Size = new Size(50, 50); skip.Text = "Skip"; skip.Click += new EventHandler(skipMethod); Controls.Add(skip); int crown = 0; TheCrown cro; int garrison = 0; Garrison gar; int ambassador = 0; AmbassadorCard amb; int settlements = 0; Settlements set; int brits = 0; Inforce bri; int scots = 0; Inforce sco; int welsh = 0; Inforce we; foreach (ActionCard r in g.getPlayer().actionCards) { if (r.used == 0) { switch (r.getinttype()) { case 0: crown = 1; cro = r; break; case 1: garrison = 1; gar = r; break; case 2: ambassador = 1; amb = r; break; case 3: set = r; settlements = 1; break; case 4: bri = r; brits = 1; break; case 5: sco = r; scots = 1; break; case 6: we = r; welsh = 1; break; } } } if (crown) { y += 55; Button btcrown = new Crown(game.map); btcrown.Location = new Point(y, 1); btcrown.Size = new Size(50, 50); btcrown.Text = "The Crown"; btcrown.Click += new EventHandler(selectCrown); Controls.Add(btcrown); } if (garrison) { y += 55; Button btcrown = new Crown(game.map); btcrown.Location = new Point(y, 1); btcrown.Size = new Size(50, 50); btcrown.Text = "Garrison"; btcrown.Click += new EventHandler(selectGarrison); Controls.Add(btcrown); } if (ambassador) { y += 55; Button btcrown = new Crown(game.map); btcrown.Location = new Point(y, 1); btcrown.Size = new Size(50, 50); btcrown.Text = "Ambassador"; btcrown.Click += new EventHandler(selectAmbassador); Controls.Add(btcrown); } if (settlements) { y += 55; Button btcrown = new Crown(game.map); btcrown.Location = new Point(y, 1); btcrown.Size = new Size(50, 50); btcrown.Text = "Ambassador"; btcrown.Click += new EventHandler(selectSettlements); Controls.Add(btcrown); } if (brits) { y += 55; Button btcrown = new Crown(game.map); btcrown.Location = new Point(y, 1); btcrown.Size = new Size(50, 50); btcrown.Text = "Ambassador"; btcrown.Click += new EventHandler(selectBritish); Controls.Add(btcrown); } if (scots) { y += 55; Button btcrown = new Crown(game.map); btcrown.Location = new Point(y, 1); btcrown.Size = new Size(50, 50); btcrown.Text = "Ambassador"; btcrown.Click += new EventHandler(selectScots); Controls.Add(btcrown); } if (welsh) { y += 55; Button btcrown = new Crown(game.map); btcrown.Location = new Point(y, 1); btcrown.Size = new Size(50, 50); btcrown.Text = "Ambassador"; btcrown.Click += new EventHandler(selectWelsh); Controls.Add(btcrown); } if (game.getCurrentPlayer().selected != null) { y = 250; Button cancle = new Button(); cancle.Location = new Point(y, 55); cancle.Size = new Size(50, 50); cancle.Text = "Cancle"; cancle.Click += new EventHandler(cancleCard); Controls.Add(cancle); y = 250 + 55; Button submit = new Button(); cancle.Location = new Point(y, 55); cancle.Size = new Size(50, 50); cancle.Text = "Submit"; cancle.Click += new EventHandler(submitAction); Controls.Add(cancle); /*Next part to work on */ switch (game.getCurrentPlayer().selected.getinttype()) { case 0: selectCrownOptions(); break; case 1: } } }
private static void OnCrownTurned(Crown crown) { Console.WriteLine($"Turned: {crown.Delta}"); }
private static void OnCrownTouched(Crown crown) { Console.WriteLine($"Touched: {crown.IsTouched}"); }
// Get items from server void ConsoleGetItems() { Crown.print("Get Items"); StartCoroutine(GetItems()); }