//STARTS public void Set_Up_Controls() { player_Rigid_Body = GetComponent <Rigidbody> (); player_Class = GetComponent <Player_Manager>().player_Class; hamster = transform.FindChild("HAM"); //Debug.Log ("P_CONTROLS was successfully setup"); }
private void createKeyIfNotExists(Player_Class player) { if (!playerToNotificationsMap.ContainsKey(player)) { playerToNotificationsMap[player] = new List <string>(); } }
public void buildFacility(Facilities_Class i, bool cost, Player_Class fact) { print("Building(2) " + i.getTypeString()); i.faction = fact.playerFaction; i.self = new Color(fact.PlayerColor.r, fact.PlayerColor.g, fact.PlayerColor.b, .5f); if (facilities[i.getType()] == null) { facilities[i.getType()] = i; } else { int temp; temp = facilities[i.getType()].getTier(); temp++; if (temp < 6) { facilities[i.getType()].setTier(temp); } else { print("Max tier structure"); cost = false; } } if (cost) { gm.calcResources(i.getTier() - 1, i.getType(), fact); } }
// Update is called once per frame void Update() { if (this.gameObject.GetComponent <Canvas>().enabled) { //print(self.GetComponent<SpriteRenderer>().name); planet_img.sprite = self.GetComponent <SpriteRenderer>().sprite; planet_name.text = self.name; if (self.GetComponent <Mine_Class>() != null) { facil[0] = self.GetComponent <Mine_Class>(); } if (self.GetComponent <Shipyard_Class>() != null) { shipyard = self.GetComponent <Shipyard_Class>(); facil[1] = shipyard; } pc = GameObject.FindObjectOfType <GameManager>().currentPlayer; if (self.GetComponent <SDS_Class>() != null) { facil[2] = self.GetComponent <SDS_Class>(); } if (self.GetComponent <Barracks_Class>() != null) { facil[3] = (Facilities_Class)self.GetComponent <Barracks_Class>(); } if (self.GetComponent <TradeCenter_Class>() != null) { facil[4] = self.GetComponent <TradeCenter_Class>(); } } }
public void addNotificationForActivePlayer(string notification) { GameManager manager = FindObjectOfType <GameManager>(); Player_Class player = manager.currentPlayer; notifications.addNotificationForPlayer(player, notification); notifications.refreshNotificationsDisplay(player); }
public void clearNotificationsForPlayer(Player_Class player) { createKeyIfNotExists(player); List <string> notifications = playerToNotificationsMap[player]; notifications.Clear(); playerToNotificationsMap[player] = notifications; }
public void clearNotifcationsForCurrentPlayer() { GameManager manager = FindObjectOfType <GameManager>(); Player_Class player = manager.currentPlayer; notifications.clearNotificationsForPlayer(player); notifications.refreshNotificationsDisplay(player); }
void Set_Up_Player() { player_Class = new Player_Class(); player_Object = gameObject; player_Controls = gameObject.AddComponent <Player_Controls>(); //setting the defaults for the components GetComponent <SphereCollider>().radius = 1f; GetComponent <SphereCollider>().material = default_Hamster_PHY_Mat; player_Controls.Set_Up_Controls(); }
public void addNotificationForPlayer(Player_Class player, string message) { createKeyIfNotExists(player); List <string> notifications = playerToNotificationsMap[player]; if (notifications.Count == NOTIFICATIONS_LIST_MAX_SIZE) { notifications.RemoveAt(0); } notifications.Add(message); playerToNotificationsMap[player] = notifications; }
public void updateHUDafterTrade() { GameManager manager = FindObjectOfType <GameManager>(); Player_Class player = manager.currentPlayer; victoryPointsText.text = player.calcVictoryPoints().ToString(); wealthText.text = player.getWealth().ToString(); achievementText.text = player.getAchievement().ToString(); commonMineralText.text = player.getCommonMineral().ToString(); uncommonMineralText.text = player.getRareMineral().ToString(); rareMineralText.text = player.getVeryRareMineral().ToString(); }
public void tradeAccept() { MainTrader = gm.currentPlayer; if (MainTrader == gm.players[0]) { SecondTrader = gm.players[1]; } else { SecondTrader = gm.players[0]; } PlayerCmnRes = MainTrader.getCommonMineral(); print("Common Resources: " + PlayerCmnRes); PlayerCmnResRequested = SecondTrader.getCommonMineral(); InputCmnHolder = int.Parse(inputForPlayer1Cmn.text); InputCmnHolderP2 = int.Parse(inputForPlayer2Cmn.text); PlayerRareRes = MainTrader.getRareMineral(); print("Rare Resources: " + PlayerRareRes); PlayerRareResRequested = SecondTrader.getRareMineral(); InputRareHolder = int.Parse(inputForPlayer1Rare.text); InputRareHolderP2 = int.Parse(inputForPlayer2Rare.text); PlayerVeryRareRes = MainTrader.getVeryRareMineral(); print("Very Rare Resources: " + PlayerVeryRareRes); PlayerVeryRareResRequested = SecondTrader.getVeryRareMineral(); InputVeryRareHolder = int.Parse(inputForPlayer1VeryRare.text); InputVeryRareHolderP2 = int.Parse(inputForPlayer2VeryRare.text); if (InputCmnHolder <= PlayerCmnRes && InputRareHolder <= PlayerRareRes && InputVeryRareHolder <= PlayerVeryRareRes) { Trade_GUI.GetComponent <Canvas>().enabled = false; TradeConfirmation.GetComponent <Canvas>().enabled = true; p1CmnTxt.text = inputForPlayer1Cmn.text; p1RareTxt.text = inputForPlayer1Rare.text; p1VRTxt.text = inputForPlayer1VeryRare.text; p2CmnTxt.text = inputForPlayer2Cmn.text; p2RareTxt.text = inputForPlayer2Rare.text; p2VRTxt.text = inputForPlayer2VeryRare.text; } else { print(InputCmnHolder + ": " + PlayerCmnRes); errorCanvas.enabled = true; print("Insufficient Minerals"); } }
public void refreshNotificationsDisplay(Player_Class player) { foreach (Transform child in transform) { GameObject.Destroy(child.gameObject); } createKeyIfNotExists(player); foreach (string notification in playerToNotificationsMap[player]) { GameObject notificationPanel = Instantiate(notificationPanelPrefab, transform.position, Quaternion.identity); notificationPanel.transform.GetChild(0).GetComponent <Text>().text = notification; notificationPanel.transform.SetParent(transform, false); } }
public void Start() { owner = self.owner; print(self.owner); int temp = 0; foreach (Facilities_Class i in facilities) { facilities[temp] = null; temp++; } gm = GameObject.FindObjectOfType <GameManager>(); }
/*public static void checkForHUDHoverOver() { * raycastResults = GetEventSystemRaycastResults(); * for(int i = 0; i < raycastResults.Count; i++) { * RaycastResult curResult = raycastResults[i]; * IHUDHoverable hoverable = curResult.gameObject.GetComponent<IHUDHoverable>(); * if(hoverable != null) { * hoverable.onHover(); * } * } * }*/ public void updateHUD() { GameManager manager = FindObjectOfType <GameManager>(); Player_Class player = manager.currentPlayer; victoryPointsText.text = player.calcVictoryPoints().ToString(); wealthText.text = player.getWealth().ToString(); achievementText.text = player.getAchievement().ToString(); commonMineralText.text = player.getCommonMineral().ToString(); uncommonMineralText.text = player.getRareMineral().ToString(); rareMineralText.text = player.getVeryRareMineral().ToString(); //turnNumber.text = manager.turnsSoFar.ToString(); clearShipInfo(); notifications.refreshNotificationsDisplay(player); }
public void endTurn() { //print(currentPlayer.playerFaction); bool movesLeft = false; foreach (Ship_Class temp in currentPlayer.playerShips) { if (temp != null) { if (temp.moves_left > 0) { movesLeft = true; } temp.newTurn(); temp.selected = false; } } //print(movesLeft); if (movesLeft == false || GameObject.Find("confirm").GetComponent <Canvas>().enabled == true) { players[0].currentTurn = !players[0].currentTurn; players[1].currentTurn = !players[1].currentTurn; foreach (Player_Class temp in players) { temp.winCon(); if (temp.currentTurn) { currentPlayer = temp; Debug.Log(hud); hud.updateHUD(); updateTurnRenderControllers(); Debug.Log(this); this.scanSystems(); } } turnsSoFar++; GameObject.Find("Next Turn").GetComponent <Canvas>().enabled = true; GameObject.Find("confirm").GetComponent <Canvas>().enabled = false; } else { GameObject.Find("confirm").GetComponent <Canvas>().enabled = true; } }
protected Ship_Class[] getShipsByType(string type) { GameManager manager = FindObjectOfType <GameManager>(); Player_Class player = manager.currentPlayer; Ship_Class[] ships = player.getPlayerShips(player.playerFaction); List <Ship_Class> matchingShips = new List <Ship_Class>(); Debug.Log("Length: " + ships.Length); foreach (Ship_Class ship in ships) { //TODO clean this up with an enum or something Debug.Log("Ship: " + ship); Debug.Log("Type: " + type); Debug.Log("Ship.getType: " + ship.getShipType()); if (ship.getShipType().Equals(type)) { matchingShips.Add(ship); } } return(matchingShips.ToArray()); }
/* * Create a new character. * * Note that we may be called with "junk" leftover in the various * fields, so we must be sure to clear them first. */ public static void player_birth(bool quickstart_allowed) { Game_Command blank = new Game_Command(Command_Code.NULL, null, null, false, 0); Game_Command cmd = blank; short[] stats = new short[(int)Stat.Max]; int[] points_spent = new int[(int)Stat.Max]; int points_left = 0; string buf; int success; bool rolled_stats = false; /* * The last character displayed, to allow the user to flick between two. * We rely on prev.age being zero to determine whether there is a stored * character or not, so initialise it here. */ Birther prev = new Birther(); /* * If quickstart is allowed, we store the old character in this, * to allow for it to be reloaded if we step back that far in the * birth process. */ Birther quickstart_prev = new Birther(); /* * If there's a quickstart character, store it for later use. * If not, default to whatever the first of the choices is. */ if (quickstart_allowed) { quickstart_prev.save_roller_data(); } else { Player.Player.instance.psex = 0; /* XXX default race/class */ Player.Player.instance.Class = Misc.classes; Player.Player.instance.Race = Misc.races; Player.Player.instance.generate(null, null, null); } /* Handle incrementing name suffix */ buf = Utilities.find_roman_suffix_start(Player_Other.instance.full_name); if (buf != null) { /* Try to increment the roman suffix */ success = Utilities.int_to_roman((Utilities.roman_to_int(buf) + 1), buf); if (success == 0) { Utilities.msg("Sorry, could not deal with suffix"); } } /* We're ready to start the interactive birth process. */ Game_Event.signal_flag(Game_Event.Event_Type.ENTER_BIRTH, quickstart_allowed); /* * Loop around until the UI tells us we have an acceptable character. * Note that it is possible to quit from inside this loop. */ while (cmd.command != Command_Code.ACCEPT_CHARACTER) { /* Grab a command from the queue - we're happy to wait for it. */ if (Game_Command.get(cmd_context.CMD_BIRTH, ref cmd, true) == null) { continue; } if (cmd.command == Command_Code.BIRTH_RESET) { Player.Player.instance.generate(null, null, null); reset_stats(stats, points_spent, ref points_left); do_birth_reset(quickstart_allowed, quickstart_prev); rolled_stats = false; } else if (cmd.command == Command_Code.CHOOSE_SEX) { Player.Player.instance.psex = (byte)cmd.arg[0].value; Player.Player.instance.generate(null, null, null); } else if (cmd.command == Command_Code.CHOOSE_RACE) { Player.Player.instance.generate(null, Player_Race.player_id2race(cmd.arg[0].value), null); reset_stats(stats, points_spent, ref points_left); generate_stats(stats, points_spent, ref points_left); rolled_stats = false; } else if (cmd.command == Command_Code.CHOOSE_CLASS) { Player.Player.instance.generate(null, null, Player_Class.player_id2class(cmd.arg[0].value)); reset_stats(stats, points_spent, ref points_left); generate_stats(stats, points_spent, ref points_left); rolled_stats = false; } else if (cmd.command == Command_Code.FINALIZE_OPTIONS) { /* Reset score options from cheat options */ for (int i = Option.CHEAT; i < Option.CHEAT + Option.N_OPTS_CHEAT; i++) { Player_Other.instance.opt[Option.SCORE + (i - Option.CHEAT)] = Player_Other.instance.opt[i]; } } else if (cmd.command == Command_Code.BUY_STAT) { /* .choice is the stat to buy */ if (!rolled_stats) { buy_stat((Stat)cmd.arg[0].value, stats, points_spent, ref points_left); } } else if (cmd.command == Command_Code.SELL_STAT) { /* .choice is the stat to sell */ if (!rolled_stats) { sell_stat((Stat)cmd.arg[0].value, stats, points_spent, ref points_left); } } else if (cmd.command == Command_Code.RESET_STATS) { /* .choice is whether to regen stats */ reset_stats(stats, points_spent, ref points_left); if (cmd.arg[0].value == 1) { generate_stats(stats, points_spent, ref points_left); } rolled_stats = false; } else if (cmd.command == Command_Code.ROLL_STATS) { throw new NotImplementedException(); //int i; //save_roller_data(&prev); ///* Get a new character */ //get_stats(stats); ///* Update stats with bonuses, etc. */ //get_bonuses(); ///* There's no real need to do this here, but it's tradition. */ //get_ahw(Player.Player.instance); //Player.Player.instance.history = get_history(Player.Player.instance.race.history, &Player.Player.instance.sc); //Player.Player.instance.sc_birth = Player.Player.instance.sc; //event_signal(EVENT_GOLD); //event_signal(EVENT_AC); //event_signal(EVENT_HP); //event_signal(EVENT_STATS); ///* Give the UI some dummy info about the points situation. */ //points_left = 0; //for (i = 0; i < A_MAX; i++) //{ // points_spent[i] = 0; //} //event_signal_birthpoints(points_spent, points_left); ///* Lock out buying and selling of stats based on rolled stats. */ //rolled_stats = true; } else if (cmd.command == Command_Code.PREV_STATS) { throw new NotImplementedException(); ///* Only switch to the stored "previous" // character if we've actually got one to load. */ //if (prev.age) //{ // load_roller_data(&prev, &prev); // get_bonuses(); //} //event_signal(EVENT_GOLD); //event_signal(EVENT_AC); //event_signal(EVENT_HP); //event_signal(EVENT_STATS); } else if (cmd.command == Command_Code.NAME_CHOICE) { /* Set player name */ Player_Other.instance.full_name = cmd.arg[0].text; //string_free((void *) cmd.arg[0].string); /* Don't change savefile name. If the UI wants it changed, they can do it. XXX (Good idea?) */ Files.process_player_name(false); } /* Various not-specific-to-birth commands. */ else if (cmd.command == Command_Code.HELP) { throw new NotImplementedException(); //char buf[80]; //strnfmt(buf, sizeof(buf), "birth.txt"); //screen_save(); //show_file(buf, null, 0, 0); //screen_load(); } else if (cmd.command == Command_Code.QUIT) { Utilities.quit(); } } roll_hp(); Squelch.birth_init(); /* Clear old messages, add new starting message */ History.clear(); History.add("Began the quest to destroy Morgoth.", History.PLAYER_BIRTH, null); /* Reset message prompt (i.e. no extraneous -more-s) */ Term.msg_flag = true; /* Note player birth in the message recall */ Message.add(" ", Message_Type.MSG_GENERIC); Message.add(" ", Message_Type.MSG_GENERIC); Message.add("====================", Message_Type.MSG_GENERIC); Message.add(" ", Message_Type.MSG_GENERIC); Message.add(" ", Message_Type.MSG_GENERIC); /* Give the player some money */ get_money(); /* Outfit the player, if they can sell the stuff */ if (!Option.birth_no_selling.value) { player_outfit(Player.Player.instance); } /* Initialise the stores */ Store.reset(); /* Now we're really done.. */ Game_Event.signal(Game_Event.Event_Type.LEAVE_BIRTH); }
public void addNotificationForPlayer(Player_Class player, string notification) { notifications.addNotificationForPlayer(player, notification); }
static void class_help(int i, object db, Region l) { int j; int k; Player_Class c = Player_Class.player_id2class(i); int len = (((int)Stat.Max) + 1) / 2; int n_flags = 0; int flag_space = 5; if (c == null) { return; } /* Output to the screen */ Misc.text_out_hook = Utilities.text_out_to_screen; /* Indent output */ Misc.text_out_indent = CLASS_AUX_COL; Term.gotoxy(CLASS_AUX_COL, TABLE_ROW); for (j = 0; j < len; j++) { string name1 = Stat_Names.Reduced[j]; string name2 = Stat_Names.Reduced[j + len]; int adj1 = c.c_adj[j] + Player.Player.instance.Race.r_adj[j]; int adj2 = c.c_adj[j + len] + Player.Player.instance.Race.r_adj[j + len]; Utilities.text_out_e("{0}{1} {2}{3}\n", name1, (adj1 > 0 ? "+" + adj1 : adj1.ToString()).PadLeft(3, ' '), name2, (adj2 > 0 ? "+" + adj2 : adj2.ToString()).PadLeft(3, ' ')); } Utilities.text_out_e("\n"); skill_help(c.c_skills, c.c_mhp, c.c_exp, -1); if (c.spell_book == TVal.TV_MAGIC_BOOK) { Utilities.text_out_e("\nLearns arcane magic"); } else if (c.spell_book == TVal.TV_PRAYER_BOOK) { Utilities.text_out_e("\nLearns divine magic"); } for (k = 0; k < Misc.PF.MAX.value; k++) { string s; if (n_flags >= flag_space) { break; } if (!c.pflags.has(k)) { continue; } s = get_pflag_desc(k); if (s == null) { continue; } Utilities.text_out_e("\n{0}", s); n_flags++; } while (n_flags < flag_space) { Utilities.text_out_e("\n"); n_flags++; } /* Reset text_out() indentation */ Misc.text_out_indent = 0; }
// Start is called before the first frame update void Awake() { x_max = 3; //Need to link to map generator x_min = -4; y_max = 4; y_min = -3; players = new Player_Class[factions.Length]; for (int i = 0; i < players.Length; i++) { players[i] = this.gameObject.AddComponent <Player_Class>(); players[i].playerFaction = factions[i]; } currentPlayer = players[0]; players[0].currentTurn = true; cost1[0, 0] = 150; //[-,X] X is facility type, - is upgrade level. Upgrade 0 is initial build cost cost1[0, 1] = 150; //Organized MINE, SHIPYARD, SDS, BARRACKS, TC cost1[0, 2] = 30; cost1[0, 3] = 30; cost1[0, 4] = 30; cost1[1, 0] = 70; cost1[1, 1] = 100; cost1[1, 2] = 0; cost1[1, 3] = 0; cost1[1, 4] = 20; cost1[2, 0] = 100; cost1[2, 1] = 170; cost1[2, 2] = 0; cost1[2, 3] = 0; cost1[2, 4] = 40; cost1[3, 0] = 120; cost1[3, 1] = 220; cost1[3, 2] = 0; cost1[3, 3] = 0; cost1[3, 4] = 80; cost1[4, 0] = 150; cost1[4, 1] = 300; cost1[4, 2] = 0; cost1[4, 3] = 0; cost1[4, 4] = 150; cost2[0, 0] = 20; //[-,X] X is facility type, - is upgrade level. Upgrade 0 is initial build cost cost2[0, 1] = 50; //Organized MINE, SHIPYARD, SDS, BARRACKS, TC cost2[0, 2] = 10; cost2[0, 3] = 10; cost2[0, 4] = 30; cost2[1, 0] = 20; cost2[1, 1] = 30; cost2[1, 2] = 0; cost2[1, 3] = 0; cost2[1, 4] = 20; cost2[2, 0] = 50; cost2[2, 1] = 60; cost2[2, 2] = 0; cost2[2, 3] = 0; cost2[2, 4] = 40; cost2[3, 0] = 80; cost2[3, 1] = 90; cost2[3, 2] = 0; cost2[3, 3] = 0; cost2[3, 4] = 80; cost2[4, 0] = 100; cost2[4, 1] = 120; cost2[4, 2] = 0; cost2[4, 3] = 0; cost2[4, 4] = 150; cost3[0, 0] = 10; //[-,X] X is facility type, - is upgrade level. Upgrade 0 is initial build cost cost3[0, 1] = 20; //Organized MINE, SHIPYARD, SDS, BARRACKS, TC cost3[0, 2] = 0; cost3[0, 3] = 0; cost3[0, 4] = 30; cost3[1, 0] = 10; cost3[1, 1] = 10; cost3[1, 2] = 0; cost3[1, 3] = 0; cost3[1, 4] = 20; cost3[2, 0] = 30; cost3[2, 1] = 30; cost3[2, 2] = 0; cost3[2, 3] = 0; cost3[2, 4] = 40; cost3[3, 0] = 50; cost3[3, 1] = 60; cost3[3, 2] = 0; cost3[3, 3] = 0; cost3[3, 4] = 80; cost3[4, 0] = 80; cost3[4, 1] = 90; cost3[4, 2] = 0; cost3[4, 3] = 0; cost3[4, 4] = 120; //Debug.Break(); }
public void calcResources(int upgrade_lvl, int type, Player_Class owner) { owner.chargeResources(cost1[upgrade_lvl, type], cost2[upgrade_lvl, type], cost3[upgrade_lvl, type]); }
public static Player GeneratePlayer() { Player p = null; string n = string.Empty; bool correct = false; Text_Buffer.Add("\nPlease enter your name: "); Text_Buffer.prompt(); n = Console.ReadLine(); while (!correct) { string newName; Text_Buffer.Add("\nIf " + n + " is correct, press < enter >\n\n\tIf it's not, please re-enter your name now:"); Text_Buffer.prompt(); newName = Console.ReadLine(); if (newName == string.Empty) { Text_Buffer.Add("\nWhat a good, strong name, " + n + "!"); correct = true; } else { n = newName; } } Player_Class pc = 0; Text_Buffer.Add("\nThere are 3 races in this game."); Text_Buffer.Add("\tThey are:"); Text_Buffer.Add("\n\t1. Rankari"); Text_Buffer.Add("\t2. Nobellus"); Text_Buffer.Add("\t3. Ginoba"); Text_Buffer.Add("\nPlease choose one: "); Text_Buffer.prompt(); string t = Console.ReadLine(); correct = false; int i = 0; while (!correct) { if (t == "1" || t == "2" || t == "3") { i = int.Parse(t); correct = true; } else { Console.WriteLine("That is not a valid choice. Try again..."); t = Console.ReadLine(); } } switch (i) { case 1: pc = Player_Class.Rankari; correct = true; break; case 2: pc = Player_Class.Nobellus; correct = true; break; case 3: pc = Player_Class.Ginoba; correct = true; break; default: Text_Buffer.Add("No race selected!"); pc = Player_Class.INCOGNITO; Text_Buffer.print(); break; } Player_Weapon pw = 0; Text_Buffer.Add("\nThere are 4 weapons in this game."); Text_Buffer.Add("\tThey are:"); Text_Buffer.Add("\n\t1. Knife"); Text_Buffer.Add("\t2. Sword"); Text_Buffer.Add("\t3. Axe"); Text_Buffer.Add("\t4. Warhammer"); Text_Buffer.Add("\nPlease choose one: "); Text_Buffer.prompt(); string s = Console.ReadLine(); correct = false; int j = 0; while (!correct) { if (s == "1" || s == "2" || s == "3" || s == "4") { j = int.Parse(s); correct = true; } else { Console.WriteLine("That is not a valid choice. Try again..."); s = Console.ReadLine(); } } switch (j) { case 1: pw = Player_Weapon.Knife; break; case 2: pw = Player_Weapon.Sword; break; case 3: pw = Player_Weapon.Axe; break; case 4: pw = Player_Weapon.WarHammer; break; default: Text_Buffer.Add("No weapon selected!"); Text_Buffer.print(); break; } switch (pc) { case Player_Class.Rankari: p = new Rankari(n, pw); break; case Player_Class.Nobellus: p = new Nobellus(n, pw); break; case Player_Class.Ginoba: p = new Ginoba(n, pw); break; default: Text_Buffer.Add("No Player Detected..."); break; } return(p); }