Beispiel #1
0
        public static void CreateGameObject(int id, Vector3 pos, Quaternion rota)
        {
            if (id > -1 && id < Prefabs.Count)
            {
                string name = id + "_" + Prefabs[id].name + "_" + index;
                switch (Net.Status)
                {
                case Corsair.NetStatus.Server:
                    NetData n = Manager.CreateNetData(NetID, (byte)NetStatus.CreateGameObject);
                    n.Write(id);
                    n.Write(name);
                    n.Write(pos);
                    n.Write(rota);
                    NetServer.Send(n);

                    Instantiate(Prefabs[id], pos, rota).name = name;
                    break;

                case Corsair.NetStatus.Client:
                    Instantiate(Prefabs[id], pos, rota).name = name;
                    break;

                case Corsair.NetStatus.Null:
                    Instantiate(Prefabs[id], pos, rota).name = name;
                    break;
                }
                index++;
            }
        }
Beispiel #2
0
        public static void SetLevel(int i)
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetData n = Manager.CreateNetData(NetID, (byte)NetStatus.SetLevel);
                n.Write(i);
                NetServer.Send(n);
                if (i != Level)
                {
                    LoadLevel(i);
                }
                break;

            case Corsair.NetStatus.Client:
                break;

            case Corsair.NetStatus.Null:
                if (i != Level)
                {
                    LoadLevel(i);
                }
                break;
            }
        }
Beispiel #3
0
        public void Hurt(AttackInfo a, IPEndPoint ignore)
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetData ns = Manager.CreateNetData(NetID, (byte)NetStatus.Hurt);
                ns.Write(a.Position);
                ns.Write(a.Rotation);
                ns.Write(a.Value);
                NetServer.Send(ns, NetType.TCP, ignore);
                break;

            case Corsair.NetStatus.Client:
                NetData nc = Manager.CreateNetData(NetID, (byte)NetStatus.Hurt);
                nc.Write(a.Position);
                nc.Write(a.Rotation);
                nc.Write(a.Value);
                NetClient.Send(nc);
                break;

            case Corsair.NetStatus.Null:
                break;
            }
            _Hurt(a);
        }
Beispiel #4
0
        public void NetDataManager(NetData data)
        {
            switch ((NetStatus)data.ReadByte())
            {
            case NetStatus.GetStatus:
                NetData n = Manager.CreateNetData(NetID, (byte)NetStatus.SetStatus);
                n.Write(Heart);
                n.Write((byte)status);
                n.Write(index);
                NetServer.Send(n);
                break;

            case NetStatus.SetStatus:
                heart  = data.ReadInt();
                status = (RoleStatus)data.ReadByte();
                SetTarget(data.ReadInt(), data.RemoteIP);
                switch (status)
                {
                case RoleStatus.Death:
                    PlayDeath(data.RemoteIP);
                    break;

                case RoleStatus.Vectory:
                    PlayVictory(data.RemoteIP);
                    break;
                }
                break;

            case NetStatus.SetTarget:
                SetTarget(data.ReadInt(), data.RemoteIP);
                break;

            case NetStatus.Idle:
                PlayIdle(data.RemoteIP);
                break;

            case NetStatus.Attacking:
                PlayAttack(data.ReadInt(), data.RemoteIP);
                break;

            case NetStatus.Moving:
                break;

            case NetStatus.Hurt:
                Corsair.AttackInfo a = new Corsair.AttackInfo();
                a.Position = data.ReadVector3();
                a.Rotation = data.ReadQuaternion();
                a.Value    = data.ReadInt();
                base.Hurt(a);
                break;

            case NetStatus.Death:
                PlayDeath(data.RemoteIP);
                break;

            case NetStatus.Victory:
                PlayVictory(data.RemoteIP);
                break;
            }
        }
Beispiel #5
0
        public override void Hurt(AttackInfo a)
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetData ns = Manager.CreateNetData(NetID, (byte)NetStatus.Hurt);
                ns.Write(a.Position);
                ns.Write(a.Rotation);
                ns.Write(a.Value);
                NetServer.Send(ns);
                break;

            case Corsair.NetStatus.Client:
                NetData nc = Manager.CreateNetData(NetID, (byte)NetStatus.Hurt);
                nc.Write(a.Position);
                nc.Write(a.Rotation);
                nc.Write(a.Value);
                NetClient.Send(nc);
                break;

            case Corsair.NetStatus.Null:
                break;
            }
            _Hurt(a);
        }
Beispiel #6
0
        public void Select(int i, IPEndPoint ignore = null)
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetData ns = Manager.CreateNetData(NetID, (byte)NetStatus.Select);
                ns.Write(i);
                NetServer.Send(ns, NetType.TCP, ignore);

                _Select(i);
                break;

            case Corsair.NetStatus.Client:
                NetData nc = Manager.CreateNetData(NetID, (byte)NetStatus.Select);
                nc.Write(i);
                NetClient.Send(nc);

                _Select(i);
                break;

            case Corsair.NetStatus.Null:
                _Select(i);
                break;
            }
            index = i;
        }
Beispiel #7
0
        public void LaunchTo(Vector3 point, IPEndPoint ignore = null)
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetData ns = Manager.CreateNetData(NetID, (byte)NetStatus.LaunchTo);
                ns.Write(point);
                NetServer.Send(ns, NetType.TCP, ignore);

                Main.LaunchTo(point);
                break;

            case Corsair.NetStatus.Client:
                NetData nc = Manager.CreateNetData(NetID, (byte)NetStatus.LaunchTo);
                nc.Write(point);
                NetClient.Send(nc);

                Main.LaunchTo(point);
                break;

            case Corsair.NetStatus.Null:
                Main.LaunchTo(point);
                break;
            }
        }
Beispiel #8
0
        public override void Hurt(Corsair.AttackInfo a)
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetData ns = Manager.CreateNetData(NetID, (byte)NetStatus.Hurt);
                ns.Write(a.Position);
                ns.Write(a.Rotation);
                ns.Write(a.Value);
                NetServer.Send(ns);
                break;

            case Corsair.NetStatus.Client:
                NetData nc = Manager.CreateNetData(NetID, (byte)NetStatus.Hurt);
                nc.Write(a.Position);
                nc.Write(a.Rotation);
                nc.Write(a.Value);
                NetClient.Send(nc);
                break;

            case Corsair.NetStatus.Null:
                break;
            }
            base.Hurt(a);
            //animator.Play("Hurt");
            //attacks.prelude.gameObject.SetActive(false);
        }
Beispiel #9
0
        public void PlayVictory(IPEndPoint ignore = null)
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetServer.Send(Manager.CreateNetData(NetID, (byte)NetStatus.Victory), NetType.TCP, ignore);
                break;

            case Corsair.NetStatus.Client:
                NetClient.Send(Manager.CreateNetData(NetID, (byte)NetStatus.Victory));
                break;

            case Corsair.NetStatus.Null:
                break;
            }
            PlayVictory();
        }
Beispiel #10
0
        public bool PlayAttack(int i, IPEndPoint ignore = null)
        {
            if (Time.time - attackLast[i] < attackCD[i])
            {
                return(false);
            }
            attackLast[i] = Time.time;
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetData ns = Manager.CreateNetData(NetID, (byte)NetStatus.Attacking);
                ns.Write(i);
                NetServer.Send(ns, NetType.TCP, ignore);
                break;

            case Corsair.NetStatus.Client:
                NetData nc = Manager.CreateNetData(NetID, (byte)NetStatus.Attacking);
                nc.Write(i);
                NetClient.Send(nc);
                break;

            case Corsair.NetStatus.Null:
                break;
            }
            switch (i)
            {
            case 0:
                isLookAt = true;
                animator.Play(attackClip[0]);
                transform.LookAt(target, Vector3.up);
                break;

            case 1:
                isLookAt = false;
                animator.Play(attackClip[1]);
                break;

            case 2:
                isLookAt = true;
                animator.Play(attackClip[2]);
                transform.LookAt(target, Vector3.up);
                break;
            }
            return(true);
        }
Beispiel #11
0
        public void PlayIdle(IPEndPoint ignore = null)
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetServer.Send(Manager.CreateNetData(NetID, (byte)NetStatus.Idle), NetType.TCP, ignore);
                break;

            case Corsair.NetStatus.Client:
                NetClient.Send(Manager.CreateNetData(NetID, (byte)NetStatus.Idle));
                break;

            case Corsair.NetStatus.Null:
                break;
            }
            animator.Play("Idle");
            attacks.prelude.gameObject.SetActive(false);
        }
Beispiel #12
0
        protected void FixedUpdate()
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetData n = Manager.CreateNetData(NetID, (byte)NetStatus.Avatar);
                n.Write(transform.position);
                n.Write(transform.rotation);
                NetServer.Send(n, NetType.UDP);
                break;

            case Corsair.NetStatus.Client:
                break;

            case Corsair.NetStatus.Null:
                break;
            }
        }
Beispiel #13
0
        public void End()
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetServer.Send(Manager.CreateNetData(NetID, (byte)NetStatus.End));
                EndEvent.Invoke();
                break;

            case Corsair.NetStatus.Client:
                EndEvent.Invoke();
                break;

            case Corsair.NetStatus.Null:
                EndEvent.Invoke();
                break;
            }
        }
Beispiel #14
0
        public override void Death()
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetData ns = Manager.CreateNetData(NetID, (byte)NetStatus.Death);
                NetServer.Send(ns);
                break;

            case Corsair.NetStatus.Client:
                NetData nc = Manager.CreateNetData(NetID, (byte)NetStatus.Death);
                NetClient.Send(nc);
                break;

            case Corsair.NetStatus.Null:
                break;
            }
            _Death();
        }
Beispiel #15
0
        private void FixedUpdate()
        {
            if (isMain)
            {
                switch (Net.Status)
                {
                case Corsair.NetStatus.Server:
                    NetServer.Send(GetAvatar(), NetType.UDP);
                    break;

                case Corsair.NetStatus.Client:
                    NetClient.Send(GetAvatar(), NetType.UDP);
                    break;

                case Corsair.NetStatus.Null:
                    break;
                }
            }
        }
Beispiel #16
0
        public void Death(IPEndPoint ignore)
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetData ns = Manager.CreateNetData(NetID, (byte)NetStatus.Death);
                NetServer.Send(ns, NetType.TCP, ignore);
                break;

            case Corsair.NetStatus.Client:
                NetData nc = Manager.CreateNetData(NetID, (byte)NetStatus.Death);
                NetClient.Send(nc);
                break;

            case Corsair.NetStatus.Null:
                break;
            }
            _Death();
        }
Beispiel #17
0
        public void SetStatus(ShipStatus s)
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetData n = Manager.CreateNetData(NetID, (byte)NetStatus.ShipStatus);
                n.Write((byte)s);
                NetServer.Send(n);

                Status = s;
                break;

            case Corsair.NetStatus.Client:
                break;

            case Corsair.NetStatus.Null:
                Status = s;
                break;
            }
        }
Beispiel #18
0
        public void Remain(float y)
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetData n = Manager.CreateNetData(NetID, (byte)NetStatus.Remain);
                n.Write(y);
                NetServer.Send(n);
                RemainEvent.Invoke(y);
                break;

            case Corsair.NetStatus.Client:
                RemainEvent.Invoke(y);
                break;

            case Corsair.NetStatus.Null:
                RemainEvent.Invoke(y);
                break;
            }
        }
Beispiel #19
0
        public override void Death()
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetServer.Send(Manager.CreateNetData(NetID, (byte)NetStatus.Death));
                break;

            case Corsair.NetStatus.Client:
                NetClient.Send(Manager.CreateNetData(NetID, (byte)NetStatus.Death));
                break;

            case Corsair.NetStatus.Null:
                break;
            }
            animator.Play("Death");
            attacks.prelude.gameObject.SetActive(false);
            StopAllCoroutines();
            base.Death();
        }
Beispiel #20
0
        public void PlayDeath(IPEndPoint ignore = null)
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetServer.Send(Manager.CreateNetData(NetID, (byte)NetStatus.Death), NetType.TCP, ignore);
                break;

            case Corsair.NetStatus.Client:
                NetClient.Send(Manager.CreateNetData(NetID, (byte)NetStatus.Death));
                break;

            case Corsair.NetStatus.Null:
                break;
            }
            animator.Play("Death");
            attacks.prelude.gameObject.SetActive(false);
            StopAllCoroutines();
            base.Death();
        }
Beispiel #21
0
        public override void Death()
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetData n = Manager.CreateNetData(NetID, (byte)NetStatus.Death);
                NetServer.Send(n);

                base.Death();
                Ramparts.Remove(this);
                break;

            case Corsair.NetStatus.Client:
                break;

            case Corsair.NetStatus.Null:
                base.Death();
                Ramparts.Remove(this);
                break;
            }
        }
Beispiel #22
0
        public void NetManager(NetData data)
        {
            switch ((NetStatus)data.ReadByte())
            {
            case NetStatus.GetStatus:
                NetData ngs = Manager.CreateNetData(NetID, (byte)NetStatus.SetStatus);
                ngs.Write(heart);
                NetServer.Send(ngs);
                break;

            case NetStatus.SetStatus:
                heart = data.ReadInt();
                if (heart > 0)
                {
                    LifeEvent.Invoke(heart / (float)max);
                }
                else
                {
                    base.Death();
                    Ramparts.Remove(this);
                }
                break;

            case NetStatus.Hurt:
                AttackInfo a = new AttackInfo();
                a.Position = data.ReadVector3();
                a.Rotation = data.ReadQuaternion();
                a.Value    = data.ReadInt();
                base.Hurt(a);
                LifeEvent.Invoke(heart / (float)max);
                break;

            case NetStatus.Death:
                base.Death();
                Ramparts.Remove(this);
                break;
            }
        }
Beispiel #23
0
        public override void Hurt(AttackInfo a)
        {
            switch (Net.Status)
            {
            case Corsair.NetStatus.Server:
                NetData n = Manager.CreateNetData(NetID, (byte)NetStatus.Hurt);
                n.Write(a.Position);
                n.Write(a.Rotation);
                n.Write(a.Value);
                NetServer.Send(n);

                base.Hurt(a);
                LifeEvent.Invoke(heart / (float)max);
                break;

            case Corsair.NetStatus.Client:
                break;

            case Corsair.NetStatus.Null:
                base.Hurt(a);
                LifeEvent.Invoke(heart / (float)max);
                break;
            }
        }