Exemple #1
0
    private void UpdateModuleInfo(CModuleInterface _tempModuleInterface)
    {
        // DEBUG: Make a random sentance to describe it
        string desc = CUtility.LoremIpsum(6, 12, 2, 4, 1);

        m_SelectedModuleType     = _tempModuleInterface.ModuleType;
        m_SelectedModuleCategory = _tempModuleInterface.ModuleCategory;
        m_SelectedModuleSize     = _tempModuleInterface.ModuleSize;
        m_SelectedModuleCost     = m_SelectedModuleSize == CModuleInterface.ESize.Small ? 400 : 800;

        // Set the name
        string name = CUtility.SplitCamelCase(m_SelectedModuleType.ToString());

        m_ModuleNameLabel.text = name;

        // Set the category
        m_ModuleCategoryLabel.text = m_SelectedModuleCategory.ToString();

        // Set the size
        UpdateSizeInfo(m_SelectedModuleSize, m_SmallModuleSprite, m_MediumModuleSprite, m_LargeModuleSprite);

        // Set the desc
        m_ModuleDescLabel.text = desc;

        // Set the cost
        m_ModuleCostLabel.text = m_SelectedModuleCost.ToString() + "N";
    }
Exemple #2
0
    void Start()
    {
        // Ensure a type of defined
        if (m_eComponentType == EType.INVALID)
        {
            Debug.LogError(string.Format("This component has not been given a component type. GameObjectName({0})", gameObject.name));
        }

        // Register self with parent module
        CModuleInterface mi = CUtility.FindInParents <CModuleInterface>(gameObject);

        if (mi != null)
        {
            mi.RegisterAttachedComponent(this);
        }
        else
        {
            Debug.LogError("Could not find module to register to");
        }

        if (EventHealthChange != null)
        {
            EventHealthChange(this, GetComponent <CActorHealth>());
        }
    }
Exemple #3
0
    private void UpdateModulePresentation()
    {
        // Create a temp module
        string     modulePrefabFile = CNetwork.Factory.GetRegisteredPrefabFile(CModuleInterface.GetPrefabType(m_CurrentModuleType.Get()));
        GameObject moduleObject     = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/" + modulePrefabFile));

        // Destroy the old module
        if (m_ParentModuleObject.transform.childCount != 0)
        {
            Destroy(m_ParentModuleObject.transform.GetChild(0).gameObject);
        }

        // Update the info
        UpdateModuleInfo(moduleObject.GetComponent <CModuleInterface>());

        // Destroy all non rendering components
        CUtility.DestroyAllNonRenderingComponents(moduleObject);

        // Add it to the child object
        moduleObject.transform.parent = m_ParentModuleObject.transform;

        // Reset some values
        CUtility.SetLayerRecursively(moduleObject, LayerMask.NameToLayer("UI 3D"));
        moduleObject.transform.localPosition = new Vector3(0.0f, -0.3f, 0.0f);
        moduleObject.transform.localRotation = Quaternion.identity;

        // Set the scale a lot smaller
        moduleObject.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
    }
Exemple #4
0
    public void RegisterModule(CModuleInterface _cModuleInterface)
    {
        if (!m_mModules.ContainsKey(_cModuleInterface.ModuleType))
        {
            m_mModules.Add(_cModuleInterface.ModuleType, new List <GameObject>());
        }

        m_mModules[_cModuleInterface.ModuleType].Add(_cModuleInterface.gameObject);
    }
Exemple #5
0
    public GameObject CreateModule(CModuleInterface.EType _eType)
    {
        GameObject cModuleObject = null;

        if (!IsModuleAttached)
        {
            cModuleObject = CNetwork.Factory.CreateObject(CModuleInterface.GetPrefabType(_eType));
            cModuleObject.GetComponent <CNetworkView>().SetPosition(m_Positioner.transform.position);
            cModuleObject.GetComponent <CNetworkView>().SetEulerAngles(m_Positioner.transform.rotation.eulerAngles);
            cModuleObject.GetComponent <CNetworkView>().SetParent(GetComponent <CNetworkView>().ViewId);

            m_cAttachedModuleViewId.Set(cModuleObject.GetComponent <CNetworkView>().ViewId);
        }
        return(cModuleObject);
    }
Exemple #6
0
 void RegisterModules()
 {
     CModuleInterface.RegisterPrefab(CModuleInterface.EType.AtmosphereGenerator, ENetworkPrefab.AtmosphereGenerator);
     CModuleInterface.RegisterPrefab(CModuleInterface.EType.PlayerSpawner, ENetworkPrefab.PlayerSpawner);
     CModuleInterface.RegisterPrefab(CModuleInterface.EType.LaserCockpit, ENetworkPrefab.LaserCockpit);
     CModuleInterface.RegisterPrefab(CModuleInterface.EType.LaserTurret, ENetworkPrefab.LaserTurret);
     CModuleInterface.RegisterPrefab(CModuleInterface.EType.PilotCockpit, ENetworkPrefab.PilotCockpit);
     CModuleInterface.RegisterPrefab(CModuleInterface.EType.PowerGenerator, ENetworkPrefab.PowerGenerator);
     CModuleInterface.RegisterPrefab(CModuleInterface.EType.PowerCapacitor, ENetworkPrefab.PowerCapacitor);
     CModuleInterface.RegisterPrefab(CModuleInterface.EType.MiningTurret, ENetworkPrefab.MiningTurret);
     CModuleInterface.RegisterPrefab(CModuleInterface.EType.MiningCockpit, ENetworkPrefab.MiningCockpit);
     //CModuleInterface.RegisterPrefab(CModuleInterface.EType.AtmosphereConditioner, ENetworkPrefab.AtmosphereConditioner);
     CModuleInterface.RegisterPrefab(CModuleInterface.EType.Dispenser, ENetworkPrefab.Dispenser);
     CModuleInterface.RegisterPrefab(CModuleInterface.EType.NaniteCapsule, ENetworkPrefab.NaniteCapsule);
     CModuleInterface.RegisterPrefab(CModuleInterface.EType.Engine, ENetworkPrefab.Engine);
 }
    void OnPlayerEnterCockpit(ulong _ulPlayerId)
    {
        CModuleInterface cSelfModuleInterface = GetComponent <CModuleInterface>();

        List <GameObject> acTurrets = null;

        switch (cSelfModuleInterface.ModuleType)
        {
        case CModuleInterface.EType.LaserCockpit:
            acTurrets = cSelfModuleInterface.ParentFacility.GetComponent <CFacilityInterface>().FindModulesByType(CModuleInterface.EType.LaserTurret);
            break;

        case CModuleInterface.EType.MiningCockpit:
            acTurrets = cSelfModuleInterface.ParentFacility.GetComponent <CFacilityInterface>().FindModulesByType(CModuleInterface.EType.MiningTurret);
            break;

        default:
            Debug.LogError("Unknown module cockpit type");
            break;
        }

        if (acTurrets != null &&
            acTurrets.Count > 0)
        {
            foreach (GameObject cTurretObject in acTurrets)
            {
                if (!cTurretObject.GetComponent <CTurretBehaviour>().IsUnderControl)
                {
                    // Notify turret that it has been mounted by player
                    cTurretObject.GetComponent <CTurretBehaviour>().TakeControl(_ulPlayerId);

                    m_cActiveTurretViewId.Set(cTurretObject.GetComponent <CNetworkView>().ViewId);

                    break;
                }
            }
        }
    }
Exemple #8
0
    void RespawnPlayer(GameObject _SourcePlayer, CPlayerHealth.HealthState _eHealthCurrentState, CPlayerHealth.HealthState _eHealthPreviousState)
    {
        // If the previous health state was DEAD
        // And current health state is ALIVE
        if (_eHealthCurrentState == CPlayerHealth.HealthState.DEAD)
        {
            // Save a list of currently constructed spawners
            List <GameObject> aPlayerSpawners = CModuleInterface.FindModulesByType(CModuleInterface.EType.PlayerSpawner);

            // Iterate through every spawner
            foreach (GameObject cPlayerSpawner in aPlayerSpawners)
            {
                // If the spawner is not blocked
                if (!cPlayerSpawner.GetComponent <CPlayerSpawnerBehaviour>().IsBlocked)
                {
                    //Ensure the collider is enabled!
                    _SourcePlayer.rigidbody.collider.enabled = true;

                    // "Board" the ship
                    // Note: Does nothing unless the player 'dies' outside the ship
                    _SourcePlayer.GetComponent <CActorBoardable>().BoardActor();

                    // Set the player's position and rotation based upon the spawner's position and rotation
                    _SourcePlayer.GetComponent <CNetworkView>().SetPosition(cPlayerSpawner.GetComponent <CPlayerSpawnerBehaviour>().m_cSpawnPosition.transform.position);
                    _SourcePlayer.GetComponent <CNetworkView>().SetRotation(cPlayerSpawner.GetComponent <CPlayerSpawnerBehaviour>().m_cSpawnPosition.transform.rotation);

                    // Heal the player to max health
                    _SourcePlayer.GetComponent <CPlayerHealth>().ApplyHeal(_SourcePlayer.GetComponent <CPlayerHealth>().MaxHealth);

                    // TODO: Reset other variables such as suit atmosphere and equipped tools

                    // Break loop
                    break;
                }
            }
        }
    }
Exemple #9
0
    void Update()
    {
        if (CNetwork.IsServer &&
            m_aUnspawnedPlayers.Count > 0)
        {
            foreach (ulong ulUnspawnedPlayerId in m_aUnspawnedPlayers.ToArray())
            {
                List <GameObject> aPlayerSpawners = CModuleInterface.FindModulesByType(CModuleInterface.EType.PlayerSpawner);

                foreach (GameObject cPlayerSpawner in aPlayerSpawners)
                {
                    if (!cPlayerSpawner.GetComponent <CPlayerSpawnerBehaviour>().IsBlocked)
                    {
                        // Create new player's actor
                        GameObject cPlayerActor = CNetwork.Factory.CreateObject((ushort)CGameRegistrator.ENetworkPrefab.PlayerActor);

                        // Set the parent as the ship
                        //cPlayerActor.GetComponent<CNetworkView>().SetParent(CGameShips.Ship.GetComponent<CNetworkView>().ViewId);

                        // Get actor network view id
                        CNetworkViewId cActorNetworkViewId = cPlayerActor.GetComponent <CNetworkView>().ViewId;

                        cPlayerActor.GetComponent <CNetworkView>().SetPosition(cPlayerSpawner.GetComponent <CPlayerSpawnerBehaviour>().m_cSpawnPosition.transform.position);
                        cPlayerActor.GetComponent <CNetworkView>().SetRotation(cPlayerSpawner.GetComponent <CPlayerSpawnerBehaviour>().m_cSpawnPosition.transform.rotation);

                        // Sync player actor view id with everyone
                        InvokeRpcAll("RegisterPlayerActor", ulUnspawnedPlayerId, cActorNetworkViewId);

                        cPlayerActor.GetComponent <CPlayerHealth>().EventHealthStateChanged += RespawnPlayer;

                        m_aUnspawnedPlayers.Remove(ulUnspawnedPlayerId);
                        break;
                    }
                }
            }
        }
    }
Exemple #10
0
    public GameObject CreateModule(CModuleInterface.EType _eType)
    {
		GameObject cModuleObject = null;
		if(!IsModuleAttached)
		{
	        cModuleObject = CNetwork.Factory.CreateObject(CModuleInterface.GetPrefabType(_eType));
	        cModuleObject.GetComponent<CNetworkView>().SetPosition(m_Positioner.transform.position);
	        cModuleObject.GetComponent<CNetworkView>().SetEulerAngles(m_Positioner.transform.rotation.eulerAngles);
	        cModuleObject.GetComponent<CNetworkView>().SetParent(GetComponent<CNetworkView>().ViewId);

	        m_cAttachedModuleViewId.Set(cModuleObject.GetComponent<CNetworkView>().ViewId);
		}
        return (cModuleObject);
    }
Exemple #11
0
	private void UpdateSizeInfo(CModuleInterface.ESize _ModuleSize, UISprite _Small, UISprite _Medium, UISprite _Large)
	{
		// Reset all colors to default
		_Small.color = Color.green;
		_Medium.color = Color.yellow;
		_Large.color = Color.red;
		
		if(_ModuleSize == CModuleInterface.ESize.Small)
		{
			_Medium.color = Color.gray;
			_Large.color = Color.gray;
		}
		else if(_ModuleSize == CModuleInterface.ESize.Medium)
		{
			_Small.color = Color.gray;
			_Large.color = Color.gray;
		}
		else if(_ModuleSize == CModuleInterface.ESize.Large)
		{
			_Small.color = Color.gray;
			_Medium.color = Color.gray;
		}
	}
Exemple #12
0
	private void UpdateModuleInfo(CModuleInterface _tempModuleInterface)
	{
		// DEBUG: Make a random sentance to describe it
		string desc = CUtility.LoremIpsum(6, 12, 2, 4, 1);

		m_SelectedModuleType = _tempModuleInterface.ModuleType;
		m_SelectedModuleCategory = _tempModuleInterface.ModuleCategory; 
		m_SelectedModuleSize = _tempModuleInterface.ModuleSize;
		m_SelectedModuleCost = m_SelectedModuleSize == CModuleInterface.ESize.Small ? 400 : 800;

		// Set the name
		string name = CUtility.SplitCamelCase(m_SelectedModuleType.ToString());
		m_ModuleNameLabel.text = name;
		
		// Set the category
		m_ModuleCategoryLabel.text = m_SelectedModuleCategory.ToString();
		
		// Set the size
		UpdateSizeInfo(m_SelectedModuleSize, m_SmallModuleSprite, m_MediumModuleSprite, m_LargeModuleSprite);
		
		// Set the desc
		m_ModuleDescLabel.text = desc;
		
		// Set the cost
		m_ModuleCostLabel.text = m_SelectedModuleCost.ToString() + "N";
	}
Exemple #13
0
	public void SetSelectedModuleType(CModuleInterface.EType _ModuleType)
	{
		m_CurrentModuleType.Set(_ModuleType);
	}
Exemple #14
0
    public void RegisterModule(CModuleInterface _cModuleInterface)
    {
        if (!m_mModules.ContainsKey(_cModuleInterface.ModuleType))
        {
            m_mModules.Add(_cModuleInterface.ModuleType, new List<GameObject>());
        }

        m_mModules[_cModuleInterface.ModuleType].Add(_cModuleInterface.gameObject);
    }
Exemple #15
0
    public List<GameObject> FindModulesByType(CModuleInterface.EType _eModuleType)
    {
        if (!m_mModules.ContainsKey(_eModuleType))
        {
            return (null);
        }

        return (m_mModules[_eModuleType]);
    }