Beispiel #1
0
    //------------------------------------------------------------------------------------
    /**
     * Handle responses from server side Extension.
     */
    public void OnExtensionResponse(BaseEvent evt)
    {
        string cmd = (string)evt.Params["cmd"];
        SFSObject dataObject = (SFSObject)evt.Params["params"];

        switch ( cmd ) {
            case "start":
                StartGame(dataObject.GetInt("t"),
                    dataObject.GetInt("p1i"),
                    dataObject.GetInt("p2i"),
                    dataObject.GetUtfString("p1n"),
                    dataObject.GetUtfString("p2n")
                    );
                break;

            case "stop":
                UserLeft();
                break;

            case "move":
                MoveReceived(dataObject.GetInt("t"), dataObject.GetInt("x"), dataObject.GetInt("y"));
                break;

            case "win":
                ShowWinner(cmd, (int)dataObject.GetInt("w"));
                break;

            case "tie":
                ShowWinner(cmd, -1);
                break;
        }
    }
    // When user variable is updated on any client, then this callback is being received
    // This is where most of the magic happens
    private void OnUserVariableUpdate(BaseEvent e)
    {
        SFSUser user = e.Params.GetSFSUser();

        if (user == smartfox.MySelf) return;
        if (!remotePlayers.ContainsKey(user)) return;

        ArrayList changedVars = e.Params.GetChangedVars();

        // Check if the remote user changed his position or rotation
        if (changedVars.Contains("x") || changedVars.Contains("y") || changedVars.Contains("z") || changedVars.Contains("rot"))
        {
            // Move the character to a new position...
            Vector3 pos = new Vector3((float)user.GetVariable("x").GetDoubleValue(), 1, (float)user.GetVariable("z").GetDoubleValue());
            Quaternion quat = Quaternion.Euler(0, (float)user.GetVariable("rot").GetDoubleValue(), 0);
            SimpleRemoteInterpolation interp = remotePlayers[user].GetComponent<SimpleRemoteInterpolation>();

            interp.SetTransform(pos, quat, true);
        }

        // Remote client got new name?
        if (changedVars.Contains("name"))
        {
            remotePlayers[user].GetComponentInChildren<TextMesh>().text = user.Name;
        }
    }
    private void OnExtensionResponse(BaseEvent evt)
    {
        try
        {
            String ResponseType = (string)evt.Params["cmd"];
            Debug.Log("Received Response: " + ResponseType);
            ISFSObject ObjectIn = (SFSObject)evt.Params["params"];
            if(ResponseType == "CharacterList")
            {
                for(int i = 0; i < ObjectIn.GetUtfStringArray("NameList").Length; i++)
                {
                    float posY = 200 - (50 + (80 * i));
                    //Debug.Log(posY);
                    CharacterPanel.Add((GameObject)Instantiate(Resources.Load("UI/CharacterPanel", typeof(GameObject))));
                    CharacterPanel[i].GetComponent<RectTransform>().parent = this.CharacterListPanel.GetComponent<RectTransform>();
                    CharacterPanel[i].GetComponent<RectTransform>().localPosition = new Vector3(0, posY, 0);
                    CharacterPanel[i].GetComponentInChildren<Text>().text = ObjectIn.GetUtfStringArray("NameList")[i];

                    GameObject aCP = CharacterPanel[i];
                    CharacterPanel[i].GetComponent<Button>().onClick.AddListener(() => CharacterPanel_Clicked(aCP));
                }
            }
        }
        catch(Exception e)
        {
            Debug.Log("Exception handling response: " + e.Message + " >>> " + e.StackTrace);
        }
    }
Beispiel #4
0
    void OnConnection(BaseEvent evt)
    {
        bool connectionSuccess = (bool)evt.Params["success"];

        Debug.Log("OnConn:" + connectionSuccess);

        if (connectionSuccess)
        {
            SFSObject loginData = new SFSObject();
            loginData.PutUtfString("username", usernameField.value);
            loginData.PutUtfString("password", passwordField.value);

            sfs.Send(new Sfs2X.Requests.LoginRequest("", "", "MainZone", loginData));

            connectionWindow.SetActive(false);
            loggingWindow.SetActive(true);
        }
        else
        {
            sfs = Connection.Instance().Reset();
            SetupListeners();

            loginWindow.SetActive(true);
            connectionWindow.SetActive(false);
        }
    }
Beispiel #5
0
        private string GetStreamName(BaseEvent @event)
        {
            var id = @event.AggregateRootId.ToString();//.Replace('-','_');    // Category name baseras på senaste dashen i streamname, därför kan inte ID:t innehålla en dash.
            var aggregateType = @event.AggregateRootType.Name;

            return $"{aggregateType}-{id}";
        }
Beispiel #6
0
 public void OnConnectionLost(BaseEvent evt)
 {
     Debug.LogError ("Lost server connection, reconnecting..");
             // Reset all internal states so we kick back to login screen
             server.RemoveAllEventListeners ();
             Application.LoadLevel ("Connector");
 }
Beispiel #7
0
 /// <summary>
 /// When connection is lost we load the login scene
 /// </summary>
 private void OnConnectionLost(BaseEvent evt)
 {
     UnsubscribeDelegates();
     Screen.lockCursor = false;
     Screen.showCursor = true;
     Application.LoadLevel("Authorization");
 }
    private void OnProximityListUpdate(BaseEvent evt)
    {
        Debug.Log("OnProximityListUpdate");

        var added = evt.Params["addedUsers"] as List<User>;
        var removed = evt.Params["removedUsers"] as List<User>;

        foreach(User user in added) {
            var entryPoint = user.AOIEntryPoint;

            GameObject playerGo = Instantiate(networkPlayerPrefab, new Vector3(entryPoint.FloatX, entryPoint.FloatY, entryPoint.FloatZ), Quaternion.identity) as GameObject;
            user.Properties.Add("GameObject", playerGo);

            users.Add(user.Id, user);
        }

        foreach(User user in removed)
        {
            object playerObj;
            user.Properties.TryGetValue("GameObject", out playerObj);

            GameObject playerGo = playerObj as GameObject;
            DestroyImmediate(playerGo);

            users.Remove(user.Id);
        }
    }
 public BaseEvent[] getActivableEvents()
 {
     int counter=0;
     if (associatedPart != null)
     {
         foreach (PartModule pm in associatedPart.GetComponents<PartModule>())
         {
             foreach (BaseEvent mEvent in pm.Events)
             {
                 if (mEvent.guiActive & mEvent.active) counter++;
             }
         }
         BaseEvent[] events = new BaseEvent[counter];
         counter = 0;
         foreach (PartModule pm in associatedPart.GetComponents<PartModule>())
         {
             foreach (BaseEvent mEvent in pm.Events)
             {
                 if (mEvent.guiActive & mEvent.active)
                 {
                     events[counter] = mEvent;
                     counter++;
                 }
             }
         }
         return events;
     }
     else return new BaseEvent[0];
 }
Beispiel #10
0
 public void OnConnectionLost(BaseEvent evt)
 {
     Debug.Log("OnConnectionLost");
     isLoggedIn = false;
     currentActiveRoom = null;
     UnregisterSFSSceneCallbacks();
 }
    private void OnUserVariablesUpdate(BaseEvent evt)
    {
        ArrayList changedVars = (ArrayList)evt.Params["changedVars"];

        SFSUser user = (SFSUser)evt.Params["user"];

        Debug.Log(user.Id);

        if(!users.ContainsKey(user.Id))
        {
            Debug.LogWarning("Got variable update for an user that is not in the users list.");
            return;
        }

        if (changedVars.Contains("x") || changedVars.Contains("y") || changedVars.Contains("z"))
        {
            GameObject playerGo = user.Properties["GameObject"] as GameObject;

            Vector3 newPosition = new Vector3();
            newPosition.x = (float)user.GetVariable("x").GetDoubleValue();
            newPosition.y = (float)user.GetVariable("y").GetDoubleValue();
            newPosition.z = (float)user.GetVariable("z").GetDoubleValue();

            playerGo.transform.position = newPosition;
        }
    }
Beispiel #12
0
    public void OnJoinRoom(BaseEvent evt)
    {
        Room room = (Room)evt.Params["room"];
        currentActiveRoom = room;

        Debug.Log("onjoinroom = " + currentActiveRoom.Name);

        if (room.Name == "The Lobby")
            Application.LoadLevel(room.Name);
        else if (room.IsGame)
        {
            //Debug.Log("is game!!!!");
            //store my own color on server as user data
            List<UserVariable> uData = new List<UserVariable>();
            uData.Add(new SFSUserVariable("playerID", GameValues.playerID));
            smartFox.Send(new SetUserVariablesRequest(uData));
            Application.LoadLevel("testScene");
        }
        else
        {
            Debug.Log("GameLobby- OnJoinRoom: joined " + room.Name);
            Application.LoadLevel("Game Lobby");
            Debug.Log("loading Game Lobby");
            //smartFox.Send(new SpectatorToPlayerRequest());
        }
    }
    private void OnUserEnterRoom(BaseEvent e)
    {
        User user = e.Params.GetUser();
        print("OnUserEnterRoom : " + user.Name);

        OnUserEnteredRoom(user);
    }
Beispiel #14
0
 public void OnProximityListUpdate(BaseEvent evt)
 {
     var addedUsers = (List<User>)evt.Params ["addedUsers"];
             var addedItems = (List<IMMOItem>)evt.Params ["addedItems"];
             var removedUsers = (List<User>)evt.Params ["removedUsers"];
             var removedItems = (List<IMMOItem>)evt.Params ["removedItems"];
             foreach (User user in addedUsers) {
                     Debug.Log ("Proximity user added: " + user);
             }
             foreach (User user in removedUsers) {
                     Debug.Log ("Proximity user removed: " + user);
             }
             foreach (IMMOItem item in addedItems) {
                     Debug.Log ("Proximity item added: " + item);
                     string type = item.GetVariable ("type").GetStringValue ();
                     if (type == "wall") {
                             AddWall (item);
                     } else if (type == "player") {
                             AddPlayer (item);
                     } else if (type == "entity") {
                             AddItem (item);
                     }
             }
             foreach (IMMOItem item in removedItems) {
                     Debug.Log ("Proximity item removed: " + item);
                     string type = item.GetVariable ("type").GetStringValue ();
                     if (type == "player") {
                             RemovePlayer (item);
                     } else if (type == "entity") {
                             RemoveItem (item);
                     }
             }
 }
 void OnUserEnterRoom(BaseEvent e)
 {
     Debug.Log ("User Enter Room");
     SmartfoxUtil.CheckParam (e.Params);
     SFSUser user = (SFSUser)e.Params ["user"];
     CreateRemotePlayer (user,Vector3.zero);
 }
Beispiel #16
0
    public void OnRoomVariablesUpdate(BaseEvent evt)
    {
        //Debug.Log("ROOM VARS");
        Room room = (Room)evt.Params["room"];
        ArrayList changedVars = (ArrayList)evt.Params["changedVars"];

        if (!GameValues.isHost)
        {
            // Check if the "gameStarted" variable was changed
            if (changedVars.Contains("gameStarted"))
            {
                if (room.GetVariable("gameStarted").GetBoolValue() == true)
                {
                    Debug.Log("Game started in room vars");
                    String[] nameParts = this.currentActiveRoom.Name.Split('-');
                    Debug.Log(nameParts[0] + " - Game");
                    smartFox.Send(new JoinRoomRequest(nameParts[0] + " - Game", "", CurrentActiveRoom.Id));
                }
                else
                {
                    Debug.Log("Game stopped");
                }
            }
        }
    }
Beispiel #17
0
    void OnConnection(BaseEvent e)
    {
        if ((bool)e.Params ["success"]) {
            Debug.Log ("Successfully Connected!");
            UnityEngine.UI.Text connectionMessage = GameObject.Find ("ConnectionMessage").GetComponent<UnityEngine.UI.Text> ();
            connectionMessage.text = "Connection Successful! \nSelect a player...";

            GameObject tetrisButton = GameObject.Find ("Tetris");
            GameObject breakoutButton = GameObject.Find ("Breakout");
            GameObject platformButton = GameObject.Find ("Platformer");
            GameObject connectionButton = GameObject.Find ("Connect");
            GameObject observerButton = GameObject.Find ("Observer");
            GameObject textField = GameObject.Find ("ServerIPInputField");

            tetrisButton.GetComponent<UnityEngine.UI.Image> ().enabled = true;
            breakoutButton.GetComponent<UnityEngine.UI.Image> ().enabled = true;
            platformButton.GetComponent<UnityEngine.UI.Image> ().enabled = true;
            observerButton.GetComponent<UnityEngine.UI.Image> ().enabled = true;

            sfs.Send(new LoginRequest(Username, "", ZoneName));
        }
        else{
            UnityEngine.UI.Text connectionMessage = GameObject.Find ("ConnectionMessage").GetComponent<UnityEngine.UI.Text> ();
            connectionMessage.text = "Connection failed.";
            Debug.Log ("Connection Failed");
        }
    }
    protected override void OnLogout(BaseEvent e)
    {
        base.OnLogout(e);

        chat.roomList.Clear();
        chat.zoneMode = 0;
    }
    protected override void OnRoomJoin(BaseEvent e)
    {
        base.OnRoomJoin(e);

        chat.roomMode = 1;
        RefreshUserList();
    }
    public void OnLogin(BaseEvent evt)
    {
        Debug.Log("Logged in successfully");

        // We either create the Game Room or join it if it exists already
        smartFox.Send(new JoinRoomRequest("The Game"));
    }
Beispiel #21
0
    protected virtual void OnLogin(BaseEvent e)
    {
        print("OnLogin");
        _isConnecting = false;

        _me = e.Params.GetUser();
    }
Beispiel #22
0
    private void OnExtensionReponse(BaseEvent evt)
    {
        string cmd = (string)evt.Params["cmd"];
        SFSObject dataObject = (SFSObject)evt.Params["params"];

        switch (cmd)
        {
            case ConfigResponseCmd.cmd_getconfig:

                int numPlayer = dataObject.GetInt("numplayer");

                for (int i = 1; i <= numPlayer; i++)
                {
                    string name = dataObject.GetUtfString("p" + i + "n");
                    int playerId = dataObject.GetInt("p" + i + "i");
                    Debug.Log("Player: " + i + " Name: " + name + " PlayerID: " + playerId);

                    if(sfs.MySelf.PlayerId== playerId)
                    {
                        Debug.Log("Myself:" + " Name: " + name + " PlayerID: " + playerId);
                        GameObject go = Resources.Load<GameObject>("Prefabs/Player");
                        GameObject player = GameObject.Instantiate(go, new Vector3(48, 10, -5), Quaternion.identity) as GameObject;
                        player.name = name;
                        Camera.main.GetComponent<CamMove>().target = go.transform;
                    }
                    else
                    {
                        GameObject go = Resources.Load<GameObject>("Prefabs/Player");
                        GameObject player= GameObject.Instantiate(go,new Vector3(48, 10, -5), Quaternion.identity) as GameObject;
                        player.name = name;
                        player.GetComponent<PlayerBehaviour>().enabled = false;

                        //Camera.main.GetComponent<CamMove>().target = go.transform;
                    }
                }
                break;

            case ConfigResponseCmd.cmd_playermove:
                string playernamemove = dataObject.GetUtfString("pn");
                int playeridmove = dataObject.GetInt("pi");

                if(sfs.MySelf.PlayerId== playeridmove)
                {
                    //Debug.Log("aaaaaaaaaaaaaaaaaa");
                    return;
                }
                else
                {
                    GameObject player = GameObject.Find(playernamemove);
                    Vector3 position = new Vector3(dataObject.GetFloat("px"), dataObject.GetFloat("py"), dataObject.GetFloat("pz"));
                    Vector3 rotation = new Vector3(dataObject.GetFloat("rx"), dataObject.GetFloat("ry"), dataObject.GetFloat("rz"));
                    player.GetComponent<Mimic>().destination = position;
                    player.GetComponent<Mimic>().rotation = rotation;
                    player.GetComponent<Mimic>().isMoving = true;
                }

                break;
        }
    }
Beispiel #23
0
 public void OnUdpInit(BaseEvent evt)
 {
     if (evt.Params.Contains("success") && !(bool)evt.Params["success"]) {
     }
     else {
         SetupRoomList();//берем список комнат
     }
 }
Beispiel #24
0
 public void OnConnectionLost(BaseEvent evt)
 {
     Debug.Log("OnConnectionLost");
     UnregisterSFSSceneCallbacks();
     currentActiveRoom = null;
     roomSelection = -1;
     Application.LoadLevel("The Lobby");
 }
    public void OnConnectionLost(BaseEvent evt)
    {
        // Reset all internal states so we kick back to login screen
        Debug.Log("OnConnectionLost");
        isJoining = false;

        serverConnectionStatusMessage = "Connection was lost, Reason: " + (string)evt.Params["reason"];
    }
    public void OnObjectMessage(BaseEvent evt)
    {
        ISFSObject message = (SFSObject)evt.Params["message"];

        if (message.GetUtfString("type") == "everyoneJoin") {
            Application.LoadLevel("GameScene");
        }
    }
Beispiel #27
0
    void OnLogin(BaseEvent evt)
    {
        var user = (Sfs2X.Entities.User)evt.Params["user"];
        Debug.Log("Login success. " + user.Name);

        loggingWindow.SetActive(false);
        sfs.Send(new Sfs2X.Requests.JoinRoomRequest("MainRoom"));
    }
Beispiel #28
0
 public static EventCommand Event(BaseEvent ev)
 {
     return new EventCommand()
     {
         BaseEvent = ev,
         TimeStamp = RTUtil.GameTime,
     };
 }
 public virtual void OnDebugMessage(BaseEvent evt)
 {
     string message = (string)evt.Params["message"];
     if (debugMessages)
     {
         Debug.Log("**** DEBUG ****" + message);
     }
 }
 void OnLogin(BaseEvent e)
 {
     Debug.Log("Welcome "+ e.Params["user"]);
     ISFSObject objOut = new SFSObject();
     objOut.PutInt("a",sumA);
     objOut.PutInt("b",sumB);
     _sfs.Send(new ExtensionRequest("SUM_INTS",objOut));
     _sfs.Send(new JoinRoomRequest(roomName));
 }
Beispiel #31
0
 void OnJoinRoom(BaseEvent e)
 {
     Debug.Log("Joined Room: " + e.Params["room"]);
     sfs.Send(new PublicMessageRequest("Hello World!"));
 }
Beispiel #32
0
 private void OnConnectionResume(BaseEvent evt)
 {
     trace("Connection resumed");
 }
Beispiel #33
0
 private void OnConnectionRetry(BaseEvent evt)
 {
     trace("Connection lost; attempting reconnection");
 }
Beispiel #34
0
 void OnLogin(BaseEvent e)
 {
     Debug.Log("Loggin In: " + e.Params["user"]);
     sfs.Send(new JoinRoomRequest(RoomName));
 }
Beispiel #35
0
    //----------------------------------------------------------
    // SmartFoxServer log event listeners
    //----------------------------------------------------------

    public void OnDebugMessage(BaseEvent evt)
    {
        string message = (string)evt.Params["message"];

        ShowLogMessage("DEBUG", message);
    }
Beispiel #36
0
 void OnLoginError(BaseEvent e)
 {
     Debug.Log("Login Error (" + e.Params["errorCode"] + "): " + e.Params["errorMessage"]);
 }
Beispiel #37
0
 void OnConfigLoad(BaseEvent e)
 {
     Debug.Log("Config File Loaded");
     sfs.Connect(sfs.Config.Host, sfs.Config.Port);
 }
Beispiel #38
0
    private void OnUserExitRoom(BaseEvent e)
    {
        SFSUser user = (SFSUser)e.Params["user"];

        RemoveRemotePlayer(user);
    }
Beispiel #39
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 private void OnSocketReconnectionTry(BaseEvent e)
 {
     DispatchEvent(new MPEvent(MPEvent.CONNECTION_RETRY));
 }
Beispiel #40
0
 //向事件字典里添加事件
 public void AddEvent(BaseEvent e)
 {
     EventDict.Add(e.eventCode, e);
 }
Beispiel #41
0
 //向事件字典里移除事件
 public void RemoveEvent(BaseEvent e)
 {
     EventDict.Remove(e.eventCode);
 }
Beispiel #42
0
 public override bool GetDebugOutput(ActorAbility instancedAbility, ActorModifier instancedModifier, BaseAbilityActor target, BaseEvent evt, ref string output)
 {
     output = string.Format("{0} 对 {1} 开始通过技能造成攻击 AttackProperty {2}", Miscs.GetDebugActorName(instancedAbility.caster), Miscs.GetDebugActorName(target), this.AttackProperty.GetDebugOutput());
     return(true);
 }
Beispiel #43
0
 public override void Call(ActorAbilityPlugin abilityPlugin, ConfigAbilityAction actionConfig, ActorAbility instancedAbility, ActorModifier instancedModifier, BaseAbilityActor target, BaseEvent evt)
 {
     abilityPlugin.DamageByAttackPropertyHandler(actionConfig, instancedAbility, instancedModifier, target, evt);
 }
Beispiel #44
0
    public void OnErrorMessage(BaseEvent evt)
    {
        string message = (string)evt.Params["message"];

        ShowLogMessage("ERROR", message);
    }
Beispiel #45
0
 private void OnPingPong(BaseEvent evt)
 {
     trace("Measured lag is: " + (int)evt.Params["lagValue"] + "ms");
 }
Beispiel #46
0
 private void OnExtensionResponse(BaseEvent e)
 {
 }
Beispiel #47
0
 private void OnLoginError(BaseEvent evt)
 {
     trace("Login failed: " + (string)evt.Params["errorMessage"]);
 }
Beispiel #48
0
 public override bool Call(ActorAbilityPlugin abilityPlugin, ActorAbility instancedAbility, ActorModifier instancedModifier, BaseAbilityActor target, BaseEvent evt)
 {
     return(abilityPlugin.ByIsPlayerAvatarHandler(this, instancedAbility, instancedModifier, target, evt));
 }
Beispiel #49
0
 private void OnConnectionLost(BaseEvent e)
 {
     sfs.RemoveAllEventListeners();
     sfs.Disconnect(); // might not need this?
     SceneManager.LoadScene("login");
 }
Beispiel #50
0
 void OnJoinRoomError(BaseEvent e)
 {
     Debug.Log("JoinRoom Error (" + e.Params["errorCode"] + "): " + e.Params["errorMessage"]);
 }
Beispiel #51
0
        private IEnumerator deployEvent()
        {
            if (USTwoScience)
            {
                RaycastHit hit;

                if (_raySource != null && Physics.Raycast(_raySource.position, _raySource.forward, out hit, 1f, LayerUtil.DefaultEquivalent))
                {
                    if (hit.collider != null)
                    {
                        bool primary   = false;
                        bool secondary = false;

                        if (hit.collider.gameObject.name == "PrimaryDoorCollider")
                        {
                            primary = true;
                        }
                        else if (hit.collider.gameObject.name == "SecondaryDoorCollider")
                        {
                            secondary = true;
                        }

                        if (primary || secondary)
                        {
                            Part p = Part.GetComponentUpwards <Part>(hit.collider.gameObject);

                            if (p != null)
                            {
                                IScalarModule scalar      = null;
                                float         deployLimit = 1;
                                PartModule    USAnimate   = null;

                                for (int i = p.Modules.Count - 1; i >= 0; i--)
                                {
                                    if (p.Modules[i].moduleName == "USAnimateGeneric")
                                    {
                                        USAnimate = p.Modules[i];

                                        if (USAnimate is IScalarModule)
                                        {
                                            scalar = USAnimate as IScalarModule;
                                        }

                                        break;
                                    }
                                }

                                if (USAnimate != null && scalar != null)
                                {
                                    BaseEvent doorEvent = null;
                                    BaseField doorLimit = null;

                                    if (primary)
                                    {
                                        doorEvent = USAnimate.Events["toggleEventPrimary"];

                                        doorLimit = USAnimate.Fields["primaryDeployLimit"];
                                    }
                                    else if (secondary)
                                    {
                                        doorEvent = USAnimate.Events["toggleEventSecondary"];

                                        doorLimit = USAnimate.Fields["secondaryDeployLimit"];
                                    }

                                    if (doorLimit != null)
                                    {
                                        deployLimit = doorLimit.GetValue <float>(USAnimate) * 0.01f;
                                    }

                                    if (doorEvent != null)
                                    {
                                        if (doorEvent.active && doorEvent.guiActive)
                                        {
                                            doorEvent.Invoke();

                                            DMUtils.Logging("Door Invoked");

                                            while (scalar.GetScalar < deployLimit)
                                            {
                                                yield return(null);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            var ownColliders = part.GetComponentsInChildren <Collider>();

                            bool flag = false;

                            for (int i = ownColliders.Length - 1; i >= 0; i--)
                            {
                                if (hit.collider == ownColliders[i])
                                {
                                    flag = true;

                                    break;
                                }
                            }

                            if (!flag)
                            {
                                ScreenMessages.PostScreenMessage(
                                    string.Format(
                                        "<b><color=orange>Obstruction detected preventing {0} from being deployed.</color></b>"
                                        , part.partInfo.title)
                                    , 5f, ScreenMessageStyle.UPPER_CENTER);

                                yield break;
                            }
                        }
                    }
                }
            }

            IsDeployed = true;

            animator(1f, 0f, Anim, animationName);

            if (USScience)
            {
                animator(1f, 0f, USAnim, USBayAnimation);
            }

            yield return(new WaitForSeconds(Anim[animationName].length));

            fullyDeployed = true;
        }
Beispiel #52
0
 private Task ProcessCatapultToEvent(BaseEvent ev)
 {
     //other events handler
     return(Task.FromResult(0));
 }
Beispiel #53
0
        public override void OnStart(StartState state)
        {
            String[] resources_to_supply = { ResourceManager.FNRESOURCE_WASTEHEAT };
            this.resources_to_supply = resources_to_supply;

            base.OnStart(state);

            radiatedThermalPower       = 0;
            convectedThermalPower      = 0;
            CurrentRadiatorTemperature = 0;
            update_count          = 0;
            radiator_deploy_delay = 0;
            explode_counter       = 0;

            DetermineGenerationType();

            maxRadiatorTemperature = (float)MaxRadiatorTemperature;

            if (hasSurfaceAreaUpgradeTechReq)
            {
                part.emissiveConstant = 1.6;
            }

            radiatorType = RadiatorType;

            effectiveRadiatorArea = EffectiveRadiatorArea;

            deployRadiatorEvent  = Events["DeployRadiator"];
            retractRadiatorEvent = Events["RetractRadiator"];

            thermalPowerConvStrField = Fields["thermalPowerConvStr"];
            radiatorIsEnabledField   = Fields["radiatorIsEnabled"];
            isAutomatedField         = Fields["isAutomated"];
            pivotEnabledField        = Fields["pivotEnabled"];

            var preventDeplyField = Fields["preventShieldedDeploy"];

            preventDeplyField.guiActive       = isDeployable;
            preventDeplyField.guiActiveEditor = isDeployable;

            Actions["DeployRadiatorAction"].guiName = Events["DeployRadiator"].guiName = "Deploy Radiator";
            Actions["ToggleRadiatorAction"].guiName = String.Format("Toggle Radiator");

            Actions["RetractRadiatorAction"].guiName = "Retract Radiator";
            Events["RetractRadiator"].guiName        = "Retract Radiator";

            var myAttachedEngine = part.FindModuleImplementing <ModuleEngines>();

            if (myAttachedEngine == null)
            {
                partMass = part.mass;
                Fields["partMass"].guiActiveEditor        = true;
                Fields["partMass"].guiActive              = true;
                Fields["convectiveBonus"].guiActiveEditor = true;
            }

            if (!String.IsNullOrEmpty(thermalAnim))
            {
                heatStates = PluginHelper.SetUpAnimation(thermalAnim, this.part);

                if (heatStates != null)
                {
                    SetHeatAnimationRatio(0);
                }
            }

            deployAnimation = part.FindModelAnimators(animName).FirstOrDefault();
            if (deployAnimation != null)
            {
                deployAnimation[animName].layer = 1;
                deployAnimation[animName].speed = 0;

                deployAnimation[animName].normalizedTime = radiatorIsEnabled ? 1 : 0;
            }

            _moduleActiveRadiator = part.FindModuleImplementing <ModuleActiveRadiator>();
            if (_moduleActiveRadiator != null)
            {
                _moduleActiveRadiator.Events["Activate"].guiActive = false;
                _moduleActiveRadiator.Events["Shutdown"].guiActive = false;
            }

            _moduleDeployableRadiator = part.FindModuleImplementing <ModuleDeployableRadiator>();
            if (_moduleDeployableRadiator != null)
            {
                radiatorState = _moduleDeployableRadiator.deployState;
            }

            BaseField radiatorfield = Fields["radiatorIsEnabled"];

            radiatorfield.guiActive        = showControls;
            radiatorfield.guiActiveEditor  = showControls;
            radiatorfield.OnValueModified += radiatorIsEnabled_OnValueModified;

            BaseField automatedfield = Fields["isAutomated"];

            automatedfield.guiActive       = showControls;
            automatedfield.guiActiveEditor = showControls;

            BaseField pivotfield = Fields["pivotEnabled"];

            pivotfield.guiActive       = showControls;
            pivotfield.guiActiveEditor = showControls;

            _maxEnergyTransfer = radiatorArea * 1000 * Math.Pow(1 + ((int)CurrentGenerationType), 1.5);

            if (_moduleActiveRadiator != null)
            {
                _moduleActiveRadiator.maxEnergyTransfer = _maxEnergyTransfer;
            }

            if (state == StartState.Editor)
            {
                return;
            }

            int depth = 0;

            star = FlightGlobals.currentMainBody;
            while (depth < 10 && star != null && star.GetTemperature(0) < 2000)
            {
                star = star.referenceBody;
                depth++;
            }
            if (star == null)
            {
                star = FlightGlobals.Bodies[0];
            }

            if (ResearchAndDevelopment.Instance != null)
            {
                upgradeCostStr = ResearchAndDevelopment.Instance.Science + "/" + upgradeCost.ToString("0") + " Science";
            }

            renderArray = part.FindModelComponents <Renderer>().ToArray();

            if (radiatorInit == false)
            {
                radiatorInit = true;
            }

            part.maxTemp = maxRadiatorTemperature;

            radiatorTempStr = maxRadiatorTemperature + "K";

            maxVacuumTemperature     = String.IsNullOrEmpty(surfaceAreaUpgradeTechReq) ? Math.Min((float)PluginHelper.RadiatorTemperatureMk3, maxRadiatorTemperature) :  Math.Min(maxVacuumTemperature, maxRadiatorTemperature);
            maxAtmosphereTemperature = String.IsNullOrEmpty(surfaceAreaUpgradeTechReq) ? Math.Min((float)PluginHelper.RadiatorTemperatureMk3, maxRadiatorTemperature) : Math.Min(maxAtmosphereTemperature, maxRadiatorTemperature);

            resourceBuffers = new ResourceBuffers();

            resourceBuffers.AddConfiguration(new ResourceBuffers.TimeBasedConfig(ResourceManager.FNRESOURCE_WASTEHEAT, wasteHeatMultiplier, 1.0e+6));

            resourceBuffers.UpdateVariable(ResourceManager.FNRESOURCE_WASTEHEAT, this.part.mass);

            resourceBuffers.Init(this.part);
        }
Beispiel #54
0
 public void OnConnectionLost(BaseEvent evt)
 {
     // Reset all internal states so we kick back to login screen
     sfs.RemoveAllEventListeners();
     SceneManager.LoadScene("Connection");
 }
Beispiel #55
0
    public void OnWarnMessage(BaseEvent evt)
    {
        string message = (string)evt.Params["message"];

        ShowLogMessage("WARN", message);
    }
Beispiel #56
0
    public void OnInfoMessage(BaseEvent evt)
    {
        string message = (string)evt.Params["message"];

        ShowLogMessage("INFO", message);
    }
Beispiel #57
0
        // 主入口实现
        public static void init(MCCSAPI api)
        {
            mapi = api;
            Console.OutputEncoding = Encoding.UTF8;
            // 从固定路径读取配置文件
            var logsetting = new Logger(LOGCONFIG);

            // 放置方块监听
            api.addAfterActListener(EventKey.onPlacedBlock, x => {
                var e = BaseEvent.getFrom(x) as PlacedBlockEvent;
                if (e == null)
                {
                    return(true);
                }
                string str = string.Format("{0} 玩家 {1} {2}在 {3} {4} 放置 {5} 方块。",
                                           title(EventKey.onPlacedBlock), e.playername,
                                           !e.isstand ? "悬空地":"",
                                           e.dimension,
                                           Coordinator(e.position),
                                           e.blockname);
                Console.WriteLine("{" + str);
                if (logsetting.autoSave)
                {
                    var t = new Thread(() => logsetting.saveLine(str));
                    t.Start();
                }
                return(true);
            });
            // 使用物品监听
            api.addAfterActListener(EventKey.onUseItem, x => {
                var e = BaseEvent.getFrom(x) as UseItemEvent;
                if (e == null)
                {
                    return(true);
                }
                if (e.RESULT)
                {
                    string str = string.Format("{0} 玩家 {1} {2}对 {3} {4} 处的 {5} 方块使用 {6} 物品。",
                                               title(EventKey.onUseItem), e.playername,
                                               !e.isstand ? "悬空地":"",
                                               e.dimension,
                                               Coordinator(e.position),
                                               e.blockname,
                                               e.itemname);
                    Console.WriteLine("{" + str);
                    if (logsetting.autoSave)
                    {
                        var t = new Thread(() => logsetting.saveLine(str));
                        t.Start();
                    }
                }
                return(true);
            });
            // 破坏方块监听
            api.addAfterActListener(EventKey.onDestroyBlock, x => {
                var e = BaseEvent.getFrom(x) as DestroyBlockEvent;
                if (e == null)
                {
                    return(true);
                }
                string str = string.Format("{0} 玩家 {1} {2}在 {3} {4} 破坏 {5} 方块。",
                                           title(EventKey.onDestroyBlock), e.playername,
                                           !e.isstand ? "悬空地":"",
                                           e.dimension,
                                           Coordinator(e.position),
                                           e.blockname);
                Console.WriteLine("{" + str);
                if (logsetting.autoSave)
                {
                    var t = new Thread(() => logsetting.saveLine(str));
                    t.Start();
                }
                return(true);
            });
            // 玩家打开箱子
            api.addAfterActListener(EventKey.onStartOpenChest, x => {
                var e = BaseEvent.getFrom(x) as StartOpenChestEvent;
                if (e == null)
                {
                    return(true);
                }
                string str = string.Format("{0} 玩家 {1} {2}在 {3} {4} 打开 {5} 箱子。",
                                           title(EventKey.onDestroyBlock), e.playername,
                                           !e.isstand ? "悬空地":"",
                                           e.dimension,
                                           Coordinator(e.position),
                                           e.blockname);
                Console.WriteLine("{" + str);
                if (logsetting.autoSave)
                {
                    var t = new Thread(() => logsetting.saveLine(str));
                    t.Start();
                }
                return(true);
            });
            // 玩家打开木桶
            api.addAfterActListener(EventKey.onStartOpenBarrel, x => {
                var e = BaseEvent.getFrom(x) as StartOpenBarrelEvent;
                if (e == null)
                {
                    return(true);
                }
                string str = string.Format("{0} 玩家 {1} {2}在 {3} {4} 打开 {5} 木桶。",
                                           title(EventKey.onDestroyBlock), e.playername,
                                           !e.isstand ? "悬空地":"",
                                           e.dimension,
                                           Coordinator(e.position),
                                           e.blockname);
                Console.WriteLine("{" + str);
                if (logsetting.autoSave)
                {
                    var t = new Thread(() => logsetting.saveLine(str));
                    t.Start();
                }
                return(true);
            });
            // 玩家关闭箱子
            api.addAfterActListener(EventKey.onStopOpenChest, x => {
                var e = BaseEvent.getFrom(x) as StopOpenChestEvent;
                if (e == null)
                {
                    return(true);
                }
                string str = string.Format("{0} 玩家 {1} {2}在 {3} {4} 关闭 {5} 箱子。",
                                           title(EventKey.onDestroyBlock), e.playername,
                                           !e.isstand ? "悬空地":"",
                                           e.dimension,
                                           Coordinator(e.position),
                                           e.blockname);
                Console.WriteLine("{" + str);
                if (logsetting.autoSave)
                {
                    var t = new Thread(() => logsetting.saveLine(str));
                    t.Start();
                }
                return(true);
            });
            // 玩家关闭木桶
            api.addAfterActListener(EventKey.onStopOpenBarrel, x => {
                var e = BaseEvent.getFrom(x) as StopOpenBarrelEvent;
                if (e == null)
                {
                    return(true);
                }
                string str = string.Format("{0} 玩家 {1} {2}在 {3} {4} 关闭 {5} 木桶。",
                                           title(EventKey.onDestroyBlock), e.playername,
                                           !e.isstand ? "悬空地" : "",
                                           e.dimension,
                                           Coordinator(e.position),
                                           e.blockname);
                Console.WriteLine("{" + str);
                if (logsetting.autoSave)
                {
                    var t = new Thread(() => logsetting.saveLine(str));
                    t.Start();
                }
                return(true);
            });
            // 放入取出物品
            api.addAfterActListener(EventKey.onSetSlot, x => {
                var e = BaseEvent.getFrom(x) as SetSlotEvent;
                if (e == null)
                {
                    return(true);
                }
                string str, str1, str2;
                str1 = string.Format("{0} 玩家 {1} {2}在 {3} {4} 的 {5} 里的第 {6} 格",
                                     title(EventKey.onSetSlot), e.playername,
                                     !e.isstand ? "悬空地" : "",
                                     e.dimension,
                                     Coordinator(e.position),
                                     e.blockname,
                                     e.slot);
                str2 = (e.itemcount > 0) ? string.Format(" 放入 {0} 个 {1} 物品。",
                                                         e.itemcount,
                                                         e.itemname) :
                       " 取出物品。";
                str = str1 + str2;
                Console.WriteLine("{" + str);
                if (logsetting.autoSave)
                {
                    var t = new Thread(() => logsetting.saveLine(str));
                    t.Start();
                }
                return(true);
            });
            // 玩家切换维度
            api.addAfterActListener(EventKey.onChangeDimension, x => {
                var e = BaseEvent.getFrom(x) as ChangeDimensionEvent;
                if (e == null)
                {
                    return(true);
                }
                if (e.RESULT)
                {
                    string str = string.Format("{0} 玩家 {1} {2}切换维度至 {3} {4}。",
                                               title(EventKey.onChangeDimension), e.playername,
                                               !e.isstand ? "悬空地" : "",
                                               e.dimension,
                                               Coordinator(e.XYZ));
                    Console.WriteLine("{" + str);
                    if (logsetting.autoSave)
                    {
                        var t = new Thread(() => logsetting.saveLine(str));
                        t.Start();
                    }
                }
                return(true);
            });
            // 命名生物死亡
            api.addAfterActListener(EventKey.onMobDie, x => {
                var e = BaseEvent.getFrom(x) as MobDieEvent;
                if (e == null)
                {
                    return(true);
                }
                if (!string.IsNullOrEmpty(e.mobname))
                {
                    string str = string.Format("{0} {1} {2} 在 {3} {4} 被 {5} 杀死了。",
                                               title(EventKey.onMobDie),
                                               string.IsNullOrEmpty(e.playername) ? "实体" : "玩家",
                                               e.mobname,
                                               toDimenStr(e.dimensionid),
                                               Coordinator(e.XYZ),
                                               e.srcname);
                    Console.WriteLine("{" + str);
                    if (logsetting.autoSave)
                    {
                        var t = new Thread(() => logsetting.saveLine(str));
                        t.Start();
                    }
                }
                return(true);
            });
            // 聊天消息
            api.addAfterActListener(EventKey.onChat, x => {
                var e = BaseEvent.getFrom(x) as ChatEvent;
                if (e == null)
                {
                    return(true);
                }
                if (e.chatstyle != "title")
                {
                    string str = string.Format("{0} {1} 说:{2}",
                                               e.playername,
                                               string.IsNullOrEmpty(e.target) ? "" : "悄悄地对 " + e.target,
                                               e.msg);
                    Console.WriteLine("{" + str);
                    if (logsetting.autoSave)
                    {
                        var t = new Thread(() => logsetting.saveLine(str));
                        t.Start();
                    }
                }
                return(true);
            });
        }
Beispiel #58
0
 void OnConfigFail(BaseEvent e)
 {
     Debug.Log("Failed to load Config File");
 }
Beispiel #59
0
 public override void Call(ActorAbilityPlugin abilityPlugin, ConfigAbilityAction actionConfig, ActorAbility instancedAbility, ActorModifier instancedModifier, BaseAbilityActor target, BaseEvent evt)
 {
     abilityPlugin.MuteAdditiveVelocityHandler(actionConfig, instancedAbility, instancedModifier, target, evt);
 }
Beispiel #60
0
 public void AddEvent(BaseEvent ev)
 {
     this.Events.Add(ev);
 }