Exemple #1
0
 protected virtual void Update()
 {
     if (transform.position.y < -1f)
     {
         ActorManager.DestroyActor(this);
     }
 }
 protected void OnZombieCreated(Actor actor)
 {
     if (Engine.ActorManager.GetPhotonView(actor).viewID == m_createdZombiePhotonViewID)
     {
         PhotonEventSender.OnActorCreated -= OnZombieCreated;
         ZombieActor _zombie = actor as ZombieActor;
         _zombie.SetIsTransformedFromOthers();
         PhotonEventSender.ShowTransformedFromOthers(_zombie);
         ReplacePlayerWithEmpty();
         ActorManager.DestroyActor(this);
     }
 }
Exemple #3
0
        protected override void OnGetHit(EventManager.HitInfo hitInfo)
        {
            if (hitInfo.HitCollider == m_collider)
            {
                GetCharacterStatus().AddHP(-hitInfo.Damage);
                if (GetCharacterStatus().HP <= 0)
                {
                    if (this == null || Engine.ActorManager == null)
                    {
                        return;
                    }

                    ActorManager.DestroyActor(this);
                }
            }
        }
 protected override void OnGetHit(EventManager.HitInfo hitInfo)
 {
     base.OnGetHit(hitInfo);
     if (hitInfo.HitCollider == m_collider)
     {
         if (Engine.ActorManager != null)
         {
             if (hitInfo.actorType == ActorFilter.ActorType.Zombie && GetCharacterStatus().HP <= 0)
             {
                 TimerManager.Schedule(2.3f, delegate
                 {
                     if (this == null || Engine.ActorManager == null)
                     {
                         return;
                     }
                     if (!NetworkManager.IsOffline)
                     {
                         if (!ActorManager.IsMyActor(this))
                         {
                             return;
                         }
                         PhotonEventSender.OnActorCreated += OnZombieCreated;
                         m_createdZombiePhotonViewID       = PhotonNetwork.AllocateViewID();
                         PhotonEventSender.CreateActor(GameManager.GameSetting.ZombieActorPrefabID, transform.position, transform.rotation.eulerAngles, m_createdZombiePhotonViewID);
                     }
                     else
                     {
                         ReplacePlayerWithEmpty();
                         Engine.ActorManager.CreateActor(GameManager.GameSetting.ZombieActorPrefabID,
                                                         delegate(Actor actor)
                         {
                             ZombieActor _zombie = actor as ZombieActor;
                             _zombie.SetIsTransformedFromOthers();
                             ActorManager.DestroyActor(this);
                         },
                                                         transform.position, transform.rotation.eulerAngles);
                     }
                 });
             }
         }
     }
 }
Exemple #5
0
    public void HandlePacket(Packet pkt)
    {
        BinaryReader reader = new BinaryReader(new MemoryStream(pkt.Data));

        Protocol p = (Protocol)reader.ReadInt16();

        switch (p)
        {
        case Protocol.ActorJoin:
        {
            short     id   = reader.ReadInt16();
            ActorType type = (ActorType)reader.ReadInt16();
            actorManager.SpawnActor(id, type);

            print("Player " + id + " joined!");
        }
        break;

        case Protocol.PlayerPossess:
        {
            short id = reader.ReadInt16();

            if (actorManager[id] != null)
            {
                (actorManager[id].Controller as PlayerController).Possess( );
            }
        }
        break;

        case Protocol.ActorLeave:
        {
            short id = reader.ReadInt16();
            actorManager.DestroyActor(id);

            print("Player " + id + " left!");
        }
        break;

        case Protocol.ActorPosition:
        {
            short id = reader.ReadInt16();

            Vector3 pos = new Vector3(
                reader.ReadSingle(),
                reader.ReadSingle(),
                reader.ReadSingle());

            if (actorManager[id] != null)
            {
                actorManager[id].ReceivePosition(pos);
            }
        }
        break;

        case Protocol.ActorRotation:
        {
            short id = reader.ReadInt16();

            float rotation = reader.ReadSingle();

            if (actorManager[id] != null)
            {
                actorManager[id].ReceiveRotation(rotation);
            }
        }
        break;

        case Protocol.PlayerInput:
        {
            short id = reader.ReadInt16();

            byte input = reader.ReadByte();

            if (actorManager[id] != null)
            {
                (actorManager[id].Controller as PlayerController).ReceiveInput(input);
            }
        }
        break;
        }
    }