コード例 #1
0
ファイル: NPCActionManager.cs プロジェクト: ylyking/lynea
    public void ReceiveActionList(SFSObject list)
    {
        SFSObject hierarchy = list.GetObj("h");
        SetServerActionHierarchy(hierarchy);
        clientActionHierarchy = (ActionList)serverActionHierarchy.Clone();

        SFSObject library = list.GetObj("l");
        SetServerActionLibrary(library);

        hasReceivedActionList = true;
    }
コード例 #2
0
ファイル: NetworkController.cs プロジェクト: ylyking/lynea
    private void SendHeadingsToGameObjects(SFSObject data)
    {
        //Debug.Log("Client gonna extract data object");
        SFSObject physicalEntities = data.GetObj("p");
        if(physicalEntities.Size() == 0) Debug.Log("erreur PE.SIZE = "+physicalEntities.Size() );
        for (int i = 0; i < physicalEntities.Size(); i++)
        {
            //Debug.Log("Client gonna extract a Physical Entity");
            SFSObject pdata = physicalEntities.GetObj(Convert.ToString(i));
            //if (pdata != null)
                //Debug.Log("Cient could extract a Physical Entity! gonna extract his uid");
            int userId = (int) pdata.GetNumber("uid");
            GameObject entity = null;

            if(userId >= 0)
            {
                //Debug.Log("Client extracted a player heading for player id="+userId);
                //Find player object with such Id
                entity = GameObject.Find("remotePlayer_"+userId);
                if(!entity)
                {
                    //create the player as he entered our interest area
                    SendMessage("UserEnterInterestArea", userId);
                    entity = GameObject.Find("remotePlayer_"+userId);
                }
            }
            else
            {
                //Debug.Log("Client extracted an NPC heading for NPC name=" + pdata.GetString("n"));
                //Find npc object with such name
                entity = GameObject.Find("npc_"+pdata.GetString("n"));
                if(!entity)
                {
                    //create the npc as he entered our interest area
                    SendMessage("NPCEnterInterestArea", pdata.GetString("n"));
                    entity = GameObject.Find("npc_"+pdata.GetString("n"));
                }
            }
            //send the entity his transform
            entity.SendMessage("ReceiveHeading", pdata);
        }
    }
コード例 #3
0
ファイル: NPCActionManager.cs プロジェクト: ylyking/lynea
    private void SetServerActionHierarchy(SFSObject hierarchy)
    {
        serverActionHierarchy = new ActionList();

        for (int a = 0; a < hierarchy.Size(); a++)
        {
            SFSObject actionObject = hierarchy.GetObj(Convert.ToString(a));
            Action action = new Action();
            action.name = actionObject.GetString("n");
            int numParam = actionObject.Size();
            for (int i = 0; i < numParam - 1; i++)
            {
                SFSObject param = actionObject.GetObj(Convert.ToString(i));
                string paramName = param.GetString("n");
                string paramType = param.GetString("t");
                switch (paramType)
                {
                    case "b" ://boolean
                        bool boolValue = param.GetBool("v");
                        action.AddBoolParam(paramName, boolValue);
                        break;
                    case "maq"://maximum quantity (integer > 0 or "MAX")
                        //
                        break;
                    case "miq"://minimum quantity (integer > 0 or "MIN")
                        //
                        break;
                    case "n"://integer with min and max values
                        //
                        break;
                    case "mi"://minored integer : integer with min value or "INF"
                        string value = param.GetString("v");
                        int minValue = (int) param.GetNumber("m");
                        action.AddMinoredIntegerParam(paramName, value, minValue);
                        break;
                    case "ii"://inventory item
                        //
                        break;
                    case "it"://item type
                        //
                        break;
                    case "am"://actionMark (an absolute position or the position of a physical entity marked by the player or his faction)
                        bool playerIsMarkOwner = param.GetBool("o");
                        int actionMarkID = (int)param.GetNumber("n");
                        action.AddActionMark(paramName, playerIsMarkOwner, actionMarkID);
                        break;
                    case "c"://character (player or npc)
                        //
                        break;
                    case "s"://string message
                        //
                        break;

                }
            }

            serverActionHierarchy.Add(action);
        }
    }
コード例 #4
0
ファイル: NetworkController.cs プロジェクト: ylyking/lynea
    private void SendAnimationMessagesToGameObjects(SFSObject data)
    {
        SFSObject physicalEntities = data.GetObj("p");
        for (int i = 0; i < physicalEntities.Size(); i++)
        {
            //Debug.Log("Client gonna extract a Physical Entity");
            SFSObject pdata = physicalEntities.GetObj(Convert.ToString(i));
            //if (pdata != null)
                //Debug.Log("Cient could extract a Physical Entity! gonna extract his uid");

            int userId = (int) pdata.GetNumber("uid");
            GameObject entity = null;

            if(userId >= 0)
            {
                //Debug.Log("Client extracted a player with id="+userId);
                //Find player object with such Id
                entity = GameObject.Find("remotePlayer_"+userId);
                if(!entity)
                {
                    //create the player as he entered our interest area
                    SendMessage("UserEnterInterestArea", userId);
                    entity = GameObject.Find("remotePlayer_"+userId);
                }
            }
            else
            {
                //Debug.Log("Client extracted an NPC named " + pdata.GetString("n"));
                //Find npc object with such name
                entity = GameObject.Find("npc_"+pdata.GetString("n"));
                if(!entity)
                {
                    //create the npc as he entered our interest area
                    SendMessage("NPCEnterInterestArea", pdata.GetString("n"));
                    entity = GameObject.Find("npc_"+pdata.GetString("n"));
                }
            }
            //send the entity his animation message
            entity.SendMessage("PlayAnimation", pdata.GetString("mes"));
        }
    }