Exemplo n.º 1
0
    public void TryKill()
    {
        RaycastHit objectHit;
        Vector3    fwd = CharacterObject.gameObject.transform.forward + new Vector3(0f, 0.5f, 0f);

        if (Physics.Raycast(CharacterObject.gameObject.transform.position, fwd, out objectHit, KillDist))
        {
            if (objectHit.collider == null || objectHit.collider.gameObject == null)
            {
                return;
            }

            Blender blender = objectHit.collider.gameObject.GetComponent <Blender>();
            if (blender != null)
            {
                Debug.Log("Killing blender:" + blender.gameObject.name);

                blender.Kill(CharacterObject.gameObject.name);

                Dictionary <string, string> data = new Dictionary <string, string> ();
                data ["id"] = blender.id;
                SocketIOComp.Emit("SERVER:KILL_BLENDER", new JSONObject(data));

                if (blender.IsNPC)
                {
                    KillerLife--;
                    KillerLifeUI [KillerLife].gameObject.SetActive(false);

                    LeanTween.value(DamageUI.gameObject, DamageClrStart, DamageClrPeak, .07f).setOnUpdate((Color val) => {
                        DamageUI.color = val;
                    }).setLoopPingPong(1);

                    if (KillerLife == 0)
                    {
                        KillerDie();
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    private void OnKillBlender(SocketIOEvent evt)
    {
        string killername = JsonToString(evt.data.GetField("killername").ToString(), "\"");
        string id         = JsonToString(evt.data.GetField("id").ToString(), "\"");

        BlenderController blenderCtrl = GetPlayerController() as BlenderController;

        if (blenderCtrl &&
            blenderCtrl.CharacterObject &&
            blenderCtrl.CharacterObject.id == id)
        {
            blenderCtrl.CharacterObject.Kill(killername);
            bool IsByPlayerWill = false;
            LeaveGame(IsByPlayerWill);
        }
        else
        {
            Blender blender = FindBlenderByID(id);
            if (blender)
            {
                blender.Kill(killername);
            }
        }
    }