Beispiel #1
0
 public void OnNetworkVarSync(INetworkVar _rSender)
 {
     m_CreateExpansionStage         = (EExpansionCreatePhase)m_ServerCreateExpansionStage.Get();
     m_LocalExpansionPortIdSelected = m_ServerLocalExpansionPortIdSelected.Get();
     m_OtherExpansionPortIdSelected = m_ServerOtherExpansionPortIdSelected.Get();
     m_FacilitySelected             = (CFacilityInterface.EType)m_ServerFacilitySelected.Get();
 }
Beispiel #2
0
    public void Update()
    {
        if (CNetwork.IsServer)
        {
            if (m_CreateExpansionStage == EExpansionCreatePhase.CreateExpansion)
            {
                CGameShips.Ship.GetComponent <CShipFacilities>().CreateFacility(m_FacilitySelected, GetComponent <CFacilityInterface>().FacilityId, m_LocalExpansionPortIdSelected, m_OtherExpansionPortIdSelected);

                m_FacilitySelected             = CFacilityInterface.EType.INVALID;
                m_LocalExpansionPortIdSelected = 0;
                m_OtherExpansionPortIdSelected = 0;
            }
        }

        if (m_CreateExpansionStage == EExpansionCreatePhase.CreateExpansion)
        {
            m_CreateExpansionStage = EExpansionCreatePhase.SelectFacilityType;
        }
        else if (m_CreateExpansionStage == EExpansionCreatePhase.SelectFacilityType)
        {
            SetupExpansionSubviewStageOne();
            m_CreateExpansionStage = EExpansionCreatePhase.INVALID;
        }
        else if (m_CreateExpansionStage == EExpansionCreatePhase.SelectLocalExpansionPort)
        {
            SetupExpansionSubviewStageTwo();
            m_CreateExpansionStage = EExpansionCreatePhase.INVALID;
        }
        else if (m_CreateExpansionStage == EExpansionCreatePhase.SelectOtherExpansionPort)
        {
            SetupExpansionSubviewStageThree();
            m_CreateExpansionStage = EExpansionCreatePhase.INVALID;
        }
    }
Beispiel #3
0
    public GameObject CreateFacility(CFacilityInterface.EType _eType, uint _uiFacilityId = uint.MaxValue, uint _uiExpansionPortId = uint.MaxValue, uint _uiAttachToId = uint.MaxValue)
    {
        CExpansionPortInterface cExpansionPort = null;

        if (_uiExpansionPortId != uint.MaxValue &&
            _uiAttachToId != uint.MaxValue)
        {
            cExpansionPort = m_mFacilities[_uiFacilityId].GetComponent <CFacilityExpansion>().GetExpansionPort(_uiExpansionPortId).GetComponent <CExpansionPortInterface>();

            if (cExpansionPort.HasAttachedFacility == true)
            {
                Debug.LogWarning("Failed to create new room. Port is already in use.");
                return(null);
            }
        }

        // Generate facility identifier
        uint uiFacilityId = m_uiFacilityIdCount;

        // Retrieve the facility prefab
        CGameRegistrator.ENetworkPrefab eRegisteredPrefab = CFacilityInterface.GetPrefabType(_eType);

        // Create facility
        GameObject cNewFacilityObject = CNetwork.Factory.CreateObject(eRegisteredPrefab);

        // Set facility properties
        CFacilityInterface cFacilityInterface = cNewFacilityObject.GetComponent <CFacilityInterface>();

        cFacilityInterface.FacilityId   = uiFacilityId;
        cFacilityInterface.FacilityType = _eType;
        m_uiFacilityIdCount++;

        // Set facility parent
        cNewFacilityObject.GetComponent <CNetworkView>().SetParent(GetComponent <CNetworkView>().ViewId);

        // Attach facility expansion port to parent expansion port
        if (cExpansionPort != null)
        {
            cExpansionPort.Attach(_uiAttachToId, cNewFacilityObject);
        }

        // Initialise the facility expansion ports
        cNewFacilityObject.GetComponent <CFacilityExpansion>().InitialiseExpansionPorts();

        // Sync position & rotation
        cNewFacilityObject.GetComponent <CNetworkView>().SyncTransformPosition();
        cNewFacilityObject.GetComponent <CNetworkView>().SyncTransformRotation();

        // Server adds the facility instantaniously
        AddNewlyCreatedFacility(cNewFacilityObject, uiFacilityId, _eType);

        // Notify facility creation observers
        if (EventOnFaciltiyCreate != null)
        {
            EventOnFaciltiyCreate(cNewFacilityObject);
        }

        return(cNewFacilityObject);
    }
Beispiel #4
0
 public List <GameObject> FindFacilities(CFacilityInterface.EType _eType)
 {
     if (m_mFacilityObjects.ContainsKey(_eType))
     {
         return(m_mFacilityObjects[_eType]);
     }
     else
     {
         return(null);
     }
 }
Beispiel #5
0
    public void AddNewlyCreatedFacility(GameObject _Facility, uint _FacilityId, CFacilityInterface.EType _FacilityType)
    {
        // Index facility against its Facility Id
        m_mFacilities.Add(_FacilityId, _Facility);

        // Index facility against its Facility Type
        if (!m_mFacilityObjects.ContainsKey(_FacilityType))
        {
            m_mFacilityObjects.Add(_FacilityType, new List <GameObject>());
        }

        m_mFacilityObjects[_FacilityType].Add(_Facility);
    }
Beispiel #6
0
	public void OnNetworkVarSync(INetworkVar _rSender)
    {
		m_CreateExpansionStage = (EExpansionCreatePhase)m_ServerCreateExpansionStage.Get();
		m_LocalExpansionPortIdSelected = m_ServerLocalExpansionPortIdSelected.Get();
		m_OtherExpansionPortIdSelected = m_ServerOtherExpansionPortIdSelected.Get();
		m_FacilitySelected = (CFacilityInterface.EType)m_ServerFacilitySelected.Get();
    }
Beispiel #7
0
	public void Update()
	{
		if(CNetwork.IsServer)
		{	
			if(m_CreateExpansionStage == EExpansionCreatePhase.CreateExpansion)
			{
				CGameShips.Ship.GetComponent<CShipFacilities>().CreateFacility(m_FacilitySelected, GetComponent<CFacilityInterface>().FacilityId, m_LocalExpansionPortIdSelected, m_OtherExpansionPortIdSelected);
				
				m_FacilitySelected = CFacilityInterface.EType.INVALID;
				m_LocalExpansionPortIdSelected = 0;
				m_OtherExpansionPortIdSelected = 0;
			}
		}
		
		if(m_CreateExpansionStage == EExpansionCreatePhase.CreateExpansion)
		{
			m_CreateExpansionStage = EExpansionCreatePhase.SelectFacilityType;
		}
		else if(m_CreateExpansionStage == EExpansionCreatePhase.SelectFacilityType)
		{
			SetupExpansionSubviewStageOne();
			m_CreateExpansionStage = EExpansionCreatePhase.INVALID;
		}
		else if(m_CreateExpansionStage == EExpansionCreatePhase.SelectLocalExpansionPort)
		{
			SetupExpansionSubviewStageTwo();
			m_CreateExpansionStage = EExpansionCreatePhase.INVALID;
		}
		else if(m_CreateExpansionStage == EExpansionCreatePhase.SelectOtherExpansionPort)
		{
			SetupExpansionSubviewStageThree();
			m_CreateExpansionStage = EExpansionCreatePhase.INVALID;
		}
	}
Beispiel #8
0
 public void ChangeFacilityType(CFacilityInterface.EType _FacilityType)
 {
     m_CurrentFacilityType.Set(_FacilityType);
 }