Inheritance: NetworkBehaviour
Beispiel #1
0
    /// <summary>
    ///     Handles messages received from DarkRift.
    /// </summary>
    /// <param name="tag">The tag.</param>
    /// <param name="subject">The subject.</param>
    /// <param name="data">The data.</param>
    void HandleOnData(byte tag, ushort subject, object data)
    {
        //If the message was a spawn message
        if (tag == SPAWN_TAG)
        {
            //The data is a reader (may want an added safety check here)
            using (DarkRiftReader reader = data as DarkRiftReader)
            {
                //Get the number of characters we will be spawning
                ushort count = reader.ReadUInt16();

                for (int i = 0; i < count; i++)
                {
                    //Read the position of the character from the reader and spawn it
                    Vector3    pos   = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                    GameObject clone = (GameObject)Instantiate(syncCharacterPrefab, pos, Quaternion.identity);

                    //Setup ID and owner of the SyncCharacter
                    SyncCharacter character = clone.GetComponent <SyncCharacter>();
                    character.ID    = reader.ReadUInt16();
                    character.owner = reader.ReadUInt16();

                    //Add to the list of characters
                    characters.Add(character.ID, character);
                }
            }
        }

        //If the message is a despawn tag
        else if (tag == DESPAWN_TAG)
        {
            //The data is a reader (may want an added safety check here)
            using (DarkRiftReader reader = data as DarkRiftReader)
            {
                //Count the number to despawn
                ushort count = reader.ReadUInt16();

                //Despawn the characters passed to us
                for (int i = 0; i < count; i++)
                {
                    Destroy(characters[reader.ReadUInt16()].gameObject);
                }
            }
        }
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        this.state = State.Outfight;
        if (isServer && SceneManager.GetActiveScene().name != "main")
        {
            this.syncBossLife = 500;
            this.syncChar = gameObject.GetComponent<SyncCharacter>();
        }
        if (!isLocalPlayer || SceneManager.GetActiveScene().name == "main")
            return;
        this.syncChar = gameObject.GetComponent<SyncCharacter>();
        this.character = gameObject.GetComponentInChildren<CharacterCollision>().gameObject;
        this.cnt = gameObject.GetComponent<Controller>();

        for (int i = 0; i < 101; i++)
            Bosslife[i] = Resources.Load<Texture2D>("Sprites/Bars/BossLife/BossLifeBar" + i.ToString());
        if (!isServer)
            return;
        infightcount = 0;
        deathCount = 0;
    }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        this.nearElement = null;
        this.character = GetComponentInChildren<CharacterCollision>().gameObject;
        this.social = GetComponent<Social_HUD>();
        this.attack = TypeAttack.None;
        this.syncCharacter = gameObject.GetComponent<SyncCharacter>();
        if (!isLocalPlayer)
            return;
        this.cam = GetComponentInChildren<Camera>().gameObject;
        this.inventaire = GetComponent<Inventory>();
        this.menu = GetComponent<Menu>();
        this.controller = GetComponent<Controller>();

        this.sucHUD = GetComponent<Success_HUD>();
        this.cristalHUD = GetComponent<Cristal_HUD>();
        this.tutoriel = GetComponent<Tutoriel>();
        this.anim = gameObject.GetComponent<Animator>();
        this.validplace = true;
        this.lastvalidplace = true;

        this.soundAudio = gameObject.GetComponent<Sound>();
        Cursor.visible = false;

        seeGUI = true;
    }
Beispiel #4
0
    // Use this for initialization
    void Start()
    {
        this.anim = gameObject.GetComponent<Animator>();
        this.cam = gameObject.GetComponentInChildren<Camera>().gameObject;
        this.character = gameObject.GetComponentInChildren<CharacterCollision>().gameObject;
        this.syncChar = gameObject.GetComponent<SyncCharacter>();

        this.im = gameObject.GetComponent<InputManager>();
        this.soundAudio = gameObject.GetComponent<Sound>();

        this.objectiv = null;
        this.loading = true;

        this.specm = gameObject.GetComponent<SpecMode> ();
        this.orbiting = false;
        this.orbsense = true;

        if (!isLocalPlayer)
        {
            this.cam.SetActive(false);
            this.character.GetComponent<AudioListener>().enabled = false;
        }

        gameObject.transform.position.Set(0, 10, 0);
    }