Exemplo n.º 1
0
    void Update()
    {
        /// INITIALIZE ///
        if (gm == null || !initialized)
        {
            GameObject gg = GameObject.Find("Gamemode");
            if (gg == null)
                return;
            gm = gg.GetComponent<Gamemode>();
            if (gm.currentState == Gamemode.State.RACING)
                initialized = true;
            else
                return;
            for (int i = 0; i < gm.GetPlayers().Count; i++)
            {


                tempIcon = Instantiate(defaultIcon);                                            // Create a minimap marker for a player
                tempIcon.transform.parent = transform;                                          // Set its parent to be minimap GameObject
                tempIcon.GetComponent<Image>().sprite = gm.GetPlayers()[i].gameObject.transform.Find("Kart").GetComponent<KartInformation>().miniMapIcon;   // Set the icon sprite to be sprite from KartInformation
                gm.GetPlayers()[i].gameObject.GetComponent<Placement>().miniMapObject = tempIcon;   // Set the created icon to be this players personal minimap icon
            }
        }

        /// UPDATE ///
        for (int i = 0; i < gm.GetPlayers().Count; i++)
        {
            pX = GetMapPos(gm.GetPlayers()[i].gameObject.transform.position.x - offSetX, mapWidth, sceneWidth);
            pZ = GetMapPos(gm.GetPlayers()[i].gameObject.transform.position.z - offSetZ, mapHeight, sceneHeight);
            gm.GetPlayers()[i].gameObject.GetComponent<Placement>().miniMapObject.GetComponent<RectTransform>().localPosition = new Vector3(pX, pZ, 0);
        }
    }
Exemplo n.º 2
0
	public bool IsModeSelected( Gamemode mode )
	{
		if( m_ModeSelection.ContainsKey( mode ) == false )
		{
			return false;
		}

		return m_ModeSelection[ mode ];
	}
Exemplo n.º 3
0
	public void SetModeSelection( Gamemode mode, bool value )
	{
		if( m_ModeSelection.ContainsKey( mode ) == false )
		{
			return;
		}

		m_ModeSelection[ mode ] = value;
	}
Exemplo n.º 4
0
	void AddMapToQueue(string map, Gamemode mode)
	{
		MapQueueEntry newEntry = new MapQueueEntry
		{
			Name = map,
			Mode = mode,
		};

		m_MapQueue.Add( newEntry );
		UpdateGamesList();
	}
Exemplo n.º 5
0
	string GetGamemodeShortform( Gamemode mode )
	{
		switch( mode )
		{
		case Gamemode.Deathmatch:
			return "DM";
		case Gamemode.CaptureTheFlag:
			return "CTF";
		case Gamemode.TeamDeathmatch:
			return "TDM";
		}

		return "N/A";
	}
Exemplo n.º 6
0
	/// <summary>
	/// This function checks the current room for it's custom properties to see which game mode 
	/// is currently being played
	/// </summary>
	void FindCurrentMapMode()
	{
		//Check if we are actually connected to a room
		if( PhotonNetwork.room == null )
		{
			return;
		}

		MapQueueEntry map = MapQueue.GetCurrentMap();

		if( map.Equals( MapQueueEntry.None ) == false )
		{
			SelectedGamemode = map.Mode;
		}
	}
	void Update () {
		if (block != null) {
			//Call Reset
			if(previousGamemode != GamemodeManager.instance.Gamemode) {
				block.Reset();
			}
			previousGamemode = GamemodeManager.instance.Gamemode;
			
			//Call Update and InactiveUpdate
			if (GamemodeManager.instance.Gamemode == Gamemode.Design) {
				block.InactiveUpdate();
			} else {
				block.Update();
			}

			//Set rotation
			transform.parent.rotation = Quaternion.Euler(0, 90 * block.GetRotation(), 0);
		}
	}
Exemplo n.º 8
0
	// Update is called once per frame
	void Update () {

        if (gamemode == null)
        {
            var dump = GameObject.Find("Gamemode");
            if(dump != null)
            gamemode = dump.GetComponent<Gamemode>();
            return;
        }
          if (PlayerNetwork.localPlayer == null)
          {
              updateWeaponTexture(InventoryScript.WEAPON.noWeapon);
              return;
          }
          InventoryScript.WEAPON currentWeapon = PlayerNetwork.localPlayer.GetComponent<InventoryScript>().currentWeapon;
        if(currentWeapon != uiweapon)
            updateWeaponTexture(currentWeapon);
        lapText.GetComponent<Text>().text = "Lap:" + PlayerNetwork.localPlayer.GetComponent<Placement>().currentLap;
        int placement = gamemode.getPlacement(PlayerNetwork.localPlayer);
       
        placementText.GetComponent<Text>().text = placement + getPlacementString(placement);

        gamemode.checkGameFinish();
	}
Exemplo n.º 9
0
	void DrawSelectModeArea()
	{
		GUILayout.Space( 5 );
		GUILayout.Label( "Selected Gamemode: " + m_SelectedMode, Styles.LabelSmall );

		for( int i = 0; i < ServerOptions.AvailableModes.Length; ++i )
		{
			bool isSelected = m_SelectedMode == ServerOptions.AvailableModes[ i ];
			bool newValue = GUILayout.Toggle( isSelected, ServerOptions.AvailableModes[ i ].ToString(), Styles.Toggle );

			if( newValue != isSelected )
			{
				m_SelectedMode = ServerOptions.AvailableModes[ i ];
			}
		}
	}
Exemplo n.º 10
0
	/// <summary>
	/// Retrieve any of the game mode components
	/// </summary>
	public GamemodeBase GetGamemode( Gamemode mode )
	{
		return m_Gamemodes[ (int)mode ];
	}
Exemplo n.º 11
0
        protected void SendData(byte[] data, Gamemode.Signature signature, bool direct = false)
        {
            var memory = new MemoryStream();
            var writer = new BinaryWriter(memory);

            writer.Write((byte) signature);
            writer.Write(data);

            Server.SendGameData(memory.ToArray(), direct);

            memory.Close();
            writer.Close();
        }
Exemplo n.º 12
0
 public void SetGamemode(Gamemode target)
 {
     SetGamemode(target, false);
 }
Exemplo n.º 13
0
        public void SetGamemode(Gamemode target, bool silent)
        {
            Gamemode = target;
            new PlayerListItem(Wrapper)
            {
                Action = 1,
                Gamemode = Gamemode,
                Uuid = Uuid
            }.Broadcast(Level);

            new ChangeGameState(Wrapper)
            {
                Reason = GameStateReason.ChangeGameMode,
                Value = (float) target
            }.Write();

            if (!silent)
            {
                ConsoleFunctions.WriteInfoLine(Username + "'s gamemode was changed to " + target.ToString("D"));
                SendChat("Your gamemode was changed to " + target.ToString(), ChatColor.Yellow);
            }
        }
Exemplo n.º 14
0
	/// <summary>
	/// Chages what map will be played for the round will be
	/// </summary>
	/// <param name="b"></param>
	public void ChangeGametype(bool gametypeBool)
	{
		if (gametypeBool)
		{
			if (m_ModeCount < ServerOptions.AvailableModes.Length)
			{
				m_ModeCount++;
				if (m_ModeCount > (ServerOptions.AvailableModes.Length - 1))
				{
					m_ModeCount = 0;
				}
			}
		}
		else
		{
			if (m_ModeCount < ServerOptions.AvailableModes.Length)
			{
				m_ModeCount--;
				if (m_ModeCount < 0)
				{
					m_ModeCount = ServerOptions.AvailableModes.Length - 1;
				}
			}
		}
		m_SelectedMode = ServerOptions.AvailableModes[m_ModeCount];
		MapNameText.text = "Mode: "+  m_SelectedMode.ToString();
	}
Exemplo n.º 15
0
 public static Gamemode GetProperty(string property, Gamemode defaultValue)
 {
     return ReadGamemode(property, defaultValue);
 }
Exemplo n.º 16
0
 public void SetGamemodeFFA()
 {
     m_gameMode = Gamemode.FFA;
 }
Exemplo n.º 17
0
	/// <summary>
	/// Set the gamemode
	/// </summary>
	/// <param name="gamemode">The gamemode to set</param>
	public void SetGamemode(Gamemode gamemode) {
		if (Gamemode != gamemode) {
			Gamemode = gamemode;
			//StartTransition();
		} else {
			Gamemode = gamemode;
		}
	}
Exemplo n.º 18
0
 public void SetGamemodeTeams()
 {
     m_gameMode = Gamemode.TEAMS;
 }
Exemplo n.º 19
0
 private static Gamemode ReadGamemode(string rule, Gamemode Default)
 {
     try
     {
         var gm = ReadString(rule);
         switch (gm)
         {
             case "1":
             case "creative":
                 return Gamemode.Creative;
             case "0":
             case "survival":
                 return Gamemode.Survival;
             case "2":
             case "adventure":
                 return Gamemode.Adventure;
             default:
                 return Default;
         }
     }
     catch
     {
         return Default;
     }
 }