コード例 #1
0
ファイル: CTorchLight.cs プロジェクト: dacuster/VOID
    public static void UnserializeInbound(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream)
    {
        while (_cStream.HasUnreadData)
        {
            ENetworkAction eAction          = (ENetworkAction)_cStream.ReadByte();
            CNetworkViewId cModuleGunViewId = _cStream.ReadNetworkViewId();

            GameObject     cModuleGunObject = cModuleGunViewId.GameObject;
            CToolInterface cToolInterface   = cModuleGunObject.GetComponent <CToolInterface>();
            CTorchLight    cTorchLight      = cModuleGunObject.GetComponent <CTorchLight>();

            switch (eAction)
            {
            case ENetworkAction.TurnOnLight:
                cTorchLight.SetActive(true);
                break;

            case ENetworkAction.TurnOffLight:
                cTorchLight.SetActive(false);
                break;

            case ENetworkAction.ToggleColour:
                cTorchLight.ToggleColour();
                break;


            default:
                Debug.LogError("Unknown network action: " + eAction);
                break;
            }
        }
    }
コード例 #2
0
    public void Start()
    {
        GetComponent <CToolInterface>().EventPrimaryActiveChange += (_bDown) =>
        {
            if (_bDown)
            {
                s_cSerializeStream.Write((byte)ENetworkAction.OpenDui);
                s_cSerializeStream.Write(ThisNetworkView.ViewId);
            }
        };

        GetComponent <CToolInterface>().EventSecondaryActiveChange += (_bDown) =>
        {
            if (_bDown)
            {
                s_cSerializeStream.Write((byte)ENetworkAction.CloseDui);
                s_cSerializeStream.Write(ThisNetworkView.ViewId);
            }
        };

        // Register the interaction events
        m_ToolInterface = gameObject.GetComponent <CToolInterface>();

        // Register DUI events
        m_DUIModuleCreationRoot = m_DUI.GetComponent <CDUIConsole>().DUI.GetComponent <CDUIModuleCreationRoot>();
        m_DUIModuleCreationRoot.EventBuildModuleButtonPressed += OnDUIBuildButtonPressed;

        // Configure DUI
        m_DUI.transform.position   = m_InactiveUITransform.position;
        m_DUI.transform.rotation   = m_InactiveUITransform.rotation;
        m_DUI.transform.localScale = m_InactiveUITransform.localScale;
    }
コード例 #3
0
    private void UpdateToolPresentation()
    {
        // Create a temp module
        string     toolPrefabFile = CNetwork.Factory.GetRegisteredPrefabFile(CToolInterface.GetPrefabType(m_CurrentToolType.Get()));
        GameObject toolObject     = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/" + toolPrefabFile));

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

        // Update the tool info
        UpdateToolInfo(toolObject.GetComponent <CToolInterface>());

        // Destroy the non rendering
        CUtility.DestroyAllNonRenderingComponents(toolObject);

        // Add it to the child object
        toolObject.transform.parent = m_ParentToolObject.transform;

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

        // Set the scale a lot smaller
        toolObject.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
    }
コード例 #4
0
    public static void UnserializeInbound(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream)
    {
        while (_cStream.HasUnreadData)
        {
            ENetworkAction eAction          = (ENetworkAction)_cStream.ReadByte();
            CNetworkViewId cModuleGunViewId = _cStream.ReadNetworkViewId();

            GameObject          cModuleGunObject    = cModuleGunViewId.GameObject;
            CToolInterface      cToolInterface      = cModuleGunObject.GetComponent <CToolInterface>();
            CModuleGunBehaviour cModuleGunBehaviour = cModuleGunObject.GetComponent <CModuleGunBehaviour>();

            switch (eAction)
            {
            case ENetworkAction.OpenDui:
                cModuleGunBehaviour.OpenDui(cToolInterface.OwnerPlayerActor.GetComponent <CPlayerInteractor>().TargetActorObject);
                break;

            case ENetworkAction.CloseDui:
                cModuleGunBehaviour.CloseDui();
                break;

            default:
                Debug.LogError("Unknown network action");
                break;
            }
        }
    }
コード例 #5
0
ファイル: CDispenserBehaviour.cs プロジェクト: dacuster/VOID
    private void SpawnTool(CToolInterface.EType _ToolType)
    {
        // Create a new object
        GameObject NewTool = CNetwork.Factory.CreateObject(CToolInterface.GetPrefabType(_ToolType));

        // Set the tool's position
        NewTool.GetComponent <CNetworkView>().SetPosition(m_ToolSpawnLocation.position);
        NewTool.GetComponent <CNetworkView>().SetEulerAngles(m_ToolSpawnLocation.eulerAngles);
    }
コード例 #6
0
ファイル: CDispenserBehaviour.cs プロジェクト: nulhax/VOID
    private void SpawnTool(CToolInterface.EType _ToolType)
    {
        // Create a new object
		GameObject NewTool = CNetwork.Factory.CreateObject(CToolInterface.GetPrefabType(_ToolType));

        // Set the tool's position
		NewTool.GetComponent<CNetworkView>().SetPosition(m_ToolSpawnLocation.position);
		NewTool.GetComponent<CNetworkView>().SetEulerAngles(m_ToolSpawnLocation.eulerAngles);
    }
コード例 #7
0
ファイル: CGameRegistrator.cs プロジェクト: dacuster/VOID
 void RegisterTools()
 {
     CToolInterface.RegisterPrefab(CToolInterface.EType.Ratchet, ENetworkPrefab.ToolRatchet);
     CToolInterface.RegisterPrefab(CToolInterface.EType.CircuitryKit, ENetworkPrefab.ToolCircuitryKit);
     CToolInterface.RegisterPrefab(CToolInterface.EType.Calibrator, ENetworkPrefab.ToolCalibrator);
     CToolInterface.RegisterPrefab(CToolInterface.EType.Fluidizer, ENetworkPrefab.ToolFluidizer);
     CToolInterface.RegisterPrefab(CToolInterface.EType.ModuleCreator, ENetworkPrefab.ToolModuleGun);
     CToolInterface.RegisterPrefab(CToolInterface.EType.FireExtinguisher, ENetworkPrefab.ToolExtinguisher);
     CToolInterface.RegisterPrefab(CToolInterface.EType.Norbert, ENetworkPrefab.ToolModuleGun);
     CToolInterface.RegisterPrefab(CToolInterface.EType.HealingKit, ENetworkPrefab.ToolMedical);
     CToolInterface.RegisterPrefab(CToolInterface.EType.AK47, ENetworkPrefab.ToolAk47);
 }
コード例 #8
0
    void OnTriggerExit(Collider TriggerObject)
    {
        CToolInterface cToolInterface = TriggerObject.GetComponent <CToolInterface>();

        if (cToolInterface)
        {
            Rigidbody RB = TriggerObject.gameObject.rigidbody;

            if (RB)
            {
                RB.velocity        = Vector3.zero;
                RB.angularVelocity = Vector3.zero;
                RB.useGravity      = true;
            }
        }
    }
コード例 #9
0
    void OnTriggerStay(Collider TriggerObject)
    {
        CToolInterface cToolInterface = TriggerObject.GetComponent <CToolInterface>();

        if (cToolInterface)
        {
            Rigidbody RB = TriggerObject.gameObject.rigidbody;

            if (RB)
            {
                RB.useGravity      = false;
                RB.velocity        = Vector3.zero;
                RB.angularVelocity = Vector3.zero;
                RB.AddForce(transform.right * -2.0f, ForceMode.Impulse);
            }
        }
    }
コード例 #10
0
    private void UpdateToolInfo(CToolInterface _tempToolInterface)
    {
        // DEBUG: Make a random sentance to describe it
        string desc = CUtility.LoremIpsum(6, 12, 2, 4, 1);

        m_SelectedToolType = _tempToolInterface.ToolType;
        m_SelectedToolCost = 100;

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

        m_ToolNameLabel.text = name;

        // Set the desc
        m_ToolDescLabel.text = desc;

        // Set the cost
        m_ToolCostLabel.text = m_SelectedToolCost.ToString() + "N";
    }
コード例 #11
0
ファイル: CPlayerBelt.cs プロジェクト: dacuster/VOID
    public void PickupTool(GameObject _cInteractableObject)
    {
        // Check object exists
        if (_cInteractableObject != null)
        {
            // Find free slot
            for (uint i = 0; i < ToolCapacity; ++i)
            {
                if (GetToolViewId(i) == null)
                {
                    // Retrieve tool interface script
                    CToolInterface cToolInterface   = _cInteractableObject.GetComponent <CToolInterface>();
                    CNetworkView   cToolNetworkView = _cInteractableObject.GetComponent <CNetworkView>();

                    // Check script found
                    if (cToolInterface == null)
                    {
                        Debug.LogError(string.Format("Target tool does not have the CToolInterface component attached! ObjectName({0})", _cInteractableObject.name));
                    }
                    else if (cToolInterface.IsHeld)
                    {
                        break;
                    }
                    else
                    {
                        m_acToolsViewId[i].Set(cToolNetworkView.ViewId);
                        cToolInterface.NotifyPickedUp(m_ulOwnerPlayerId);
                        ChangeTool((byte)i);
                        // Commented out by Nathan to avoid extraneous debug information.
                        // Feel free to uncomment for debugging purposes when required.
                        //Debug.Log(string.Format("Picked up tool. PlayerId({0}) ToolObjectName({1}) SlotId({2})", _ulPlayerId, _cInteractableObject.name, i));
                    }
                    break;
                }
            }
        }
    }
コード例 #12
0
ファイル: CDUIDispenserRoot.cs プロジェクト: nulhax/VOID
	public void SetSelectedToolType(CToolInterface.EType _ToolType)
	{
		m_CurrentToolType.Set(_ToolType);
	}
コード例 #13
0
ファイル: CDUIDispenserRoot.cs プロジェクト: nulhax/VOID
	private void UpdateToolInfo(CToolInterface _tempToolInterface)
	{
		// DEBUG: Make a random sentance to describe it
		string desc = CUtility.LoremIpsum(6, 12, 2, 4, 1);
		
		m_SelectedToolType = _tempToolInterface.ToolType;
		m_SelectedToolCost = 100;
		
		// Set the name
		string name = CUtility.SplitCamelCase(m_SelectedToolType.ToString());
		m_ToolNameLabel.text = name;
		
		// Set the desc
		m_ToolDescLabel.text = desc;
		
		// Set the cost
		m_ToolCostLabel.text = m_SelectedToolCost.ToString() + "N";
	}
コード例 #14
0
ファイル: CModuleGunBehaviour.cs プロジェクト: nulhax/VOID
	public void Start()
	{
        GetComponent<CToolInterface>().EventPrimaryActiveChange += (_bDown) =>
        {
            if (_bDown)
            {
                s_cSerializeStream.Write((byte)ENetworkAction.OpenDui);
                s_cSerializeStream.Write(ThisNetworkView.ViewId);
            }
        };

        GetComponent<CToolInterface>().EventSecondaryActiveChange += (_bDown) =>
        {
            if (_bDown)
            {
                s_cSerializeStream.Write((byte)ENetworkAction.CloseDui);
                s_cSerializeStream.Write(ThisNetworkView.ViewId);
            }
        };

		// Register the interaction events
		m_ToolInterface = gameObject.GetComponent<CToolInterface>();

		// Register DUI events
		m_DUIModuleCreationRoot = m_DUI.GetComponent<CDUIConsole>().DUI.GetComponent<CDUIModuleCreationRoot>();
		m_DUIModuleCreationRoot.EventBuildModuleButtonPressed += OnDUIBuildButtonPressed;

		// Configure DUI
		m_DUI.transform.position = m_InactiveUITransform.position;
		m_DUI.transform.rotation = m_InactiveUITransform.rotation;
		m_DUI.transform.localScale = m_InactiveUITransform.localScale;
	}