|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- using Protobuf;
- using System.Collections.Generic;
- using GameClass.GameObj;
- /*
- namespace Server
- {
- public static class CopyInfo
- {
- public static MessageToClient.Types.GameObjMessage? Auto(GameObj gameObj)
- {
- if (gameObj.Type == Preparation.Utility.GameObjType.Character)
- return Player((Character)gameObj);
- else if (gameObj.Type == Preparation.Utility.GameObjType.Bullet)
- return Bullet((Bullet)gameObj);
- else if (gameObj.Type == Preparation.Utility.GameObjType.Prop)
- return Prop((Prop)gameObj);
- else if (gameObj.Type == Preparation.Utility.GameObjType.BombedBullet)
- return BombedBullet((BombedBullet)gameObj);
- else if (gameObj.Type == Preparation.Utility.GameObjType.PickedProp)
- return PickedProp((PickedProp)gameObj);
- else return null; //先写着防报错
- }
-
- private static MessageToClient.Types.GameObjMessage Player(Character player)
- {
- MessageToClient.Types.GameObjMessage msg = new MessageToClient.Types.GameObjMessage();
- msg.MessageOfCharacter = new MessageOfCharacter();
-
- msg.MessageOfCharacter.X = player.Position.x;
- msg.MessageOfCharacter.Y = player.Position.y;
- msg.MessageOfCharacter.AttackRange = player.AttackRange;
- msg.MessageOfCharacter.BulletNum = player.BulletNum;
- msg.MessageOfCharacter.CanMove = player.CanMove;
- msg.MessageOfCharacter.CD = player.CD;
- msg.MessageOfCharacter.GemNum = player.GemNum;
- msg.MessageOfCharacter.Guid = player.ID;
- msg.MessageOfCharacter.IsResetting = player.IsResetting;
- msg.MessageOfCharacter.Life = player.HP;
- msg.MessageOfCharacter.LifeNum = player.DeathCount + 1;
- msg.MessageOfCharacter.Radius = player.Radius;
- msg.MessageOfCharacter.Speed = player.MoveSpeed;
- msg.MessageOfCharacter.TimeUntilCommonSkillAvailable = player.TimeUntilCommonSkillAvailable;
- msg.MessageOfCharacter.TeamID = player.TeamID;
- msg.MessageOfCharacter.PlayerID = player.PlayerID;
- msg.MessageOfCharacter.IsInvisible = player.IsInvisible;
- msg.MessageOfCharacter.FacingDirection = player.FacingDirection;
-
- //应该要发队伍分数,这里先发个人分数
- msg.MessageOfCharacter.Score = player.Score;
-
- //这条暂时没啥用
- msg.MessageOfCharacter.TimeUntilUltimateSkillAvailable = 0;
-
- msg.MessageOfCharacter.Vampire = player.Vampire;
- foreach (KeyValuePair<Preparation.Utility.BuffType, bool> kvp in player.Buff)
- {
- if (kvp.Value)
- {
- switch(kvp.Key)
- {
- case Preparation.Utility.BuffType.Spear:
- msg.MessageOfCharacter.Buff.Add(BuffType.SpearBuff);
- break;
- case Preparation.Utility.BuffType.AddLIFE:
- msg.MessageOfCharacter.Buff.Add(BuffType.AddLife);
- break;
- case Preparation.Utility.BuffType.Shield:
- msg.MessageOfCharacter.Buff.Add(BuffType.ShieldBuff);
- break;
- case Preparation.Utility.BuffType.AddSpeed:
- msg.MessageOfCharacter.Buff.Add(BuffType.MoveSpeed);
- break;
- default:
- break;
- }
- }
- }
- switch (player.Place)
- {
- case Preparation.Utility.PlacccceType.Land:
- msg.MessageOfCharacter.Place = Communication.Proto.PlacccceType.Land;
- break;
- case Preparation.Utility.PlacccceType.Grass1:
- msg.MessageOfCharacter.Place = Communication.Proto.PlacccceType.Grass1;
- break;
- case Preparation.Utility.PlacccceType.Grass2:
- msg.MessageOfCharacter.Place = Communication.Proto.PlacccceType.Grass2;
- break;
- case Preparation.Utility.PlacccceType.Grass3:
- msg.MessageOfCharacter.Place = Communication.Proto.PlacccceType.Grass3;
- break;
- // case Preparation.Utility.PlacccceType.Invisible:
- // msg.MessageOfCharacter.Place = Communication.Proto.PlacccceType.Invisible;
- // break;
- default:
- msg.MessageOfCharacter.Place = Communication.Proto.PlacccceType.NullPlaceType;
- break;
- }
-
- //Character的储存方式可能得改,用enum type存道具和子弹,不应该用对象
- //现在懒得改了,有时间再重整一波
- if (player.PropInventory == null)
- msg.MessageOfCharacter.Prop = Communication.Proto.PropType.NullPropType;
- else
- {
- switch (player.PropInventory.GetPropType())
- {
- case Preparation.Utility.PropType.Gem:
- msg.MessageOfCharacter.Prop = Communication.Proto.PropType.Gem;
- break;
- case Preparation.Utility.PropType.addLIFE:
- msg.MessageOfCharacter.Prop = Communication.Proto.PropType.AddLife;
- break;
- case Preparation.Utility.PropType.addSpeed:
- msg.MessageOfCharacter.Prop = Communication.Proto.PropType.AddSpeed;
- break;
- case Preparation.Utility.PropType.Shield:
- msg.MessageOfCharacter.Prop = Communication.Proto.PropType.Shield;
- break;
- case Preparation.Utility.PropType.Spear:
- msg.MessageOfCharacter.Prop = Communication.Proto.PropType.Spear;
- break;
- default:
- msg.MessageOfCharacter.Prop = Communication.Proto.PropType.NullPropType;
- break;
- }
- }
- switch (player.PassiveSkillType)
- {
- case Preparation.Utility.PassiveSkillType.RecoverAfterBattle:
- msg.MessageOfCharacter.PassiveSkillType = Communication.Proto.PassiveSkillType.RecoverAfterBattle;
- break;
- case Preparation.Utility.PassiveSkillType.SpeedUpWhenLeavingGrass:
- msg.MessageOfCharacter.PassiveSkillType = Communication.Proto.PassiveSkillType.SpeedUpWhenLeavingGrass;
- break;
- case Preparation.Utility.PassiveSkillType.Vampire:
- msg.MessageOfCharacter.PassiveSkillType = Communication.Proto.PassiveSkillType.Vampire;
- break;
- default:
- msg.MessageOfCharacter.PassiveSkillType = Communication.Proto.PassiveSkillType.NullPassiveSkillType;
- break;
- }
- switch (player.CommonSkillType)
- {
- case Preparation.Utility.ActiveSkillType.BecomeAssassin:
- msg.MessageOfCharacter.ActiveSkillType = Communication.Proto.ActiveSkillType.BecomeAssassin;
- break;
- case Preparation.Utility.ActiveSkillType.BecomeVampire:
- msg.MessageOfCharacter.ActiveSkillType = Communication.Proto.ActiveSkillType.BecomeVampire;
- break;
- case Preparation.Utility.ActiveSkillType.NuclearWeapon:
- msg.MessageOfCharacter.ActiveSkillType = Communication.Proto.ActiveSkillType.NuclearWeapon;
- break;
- case Preparation.Utility.ActiveSkillType.SuperFast:
- msg.MessageOfCharacter.ActiveSkillType = Communication.Proto.ActiveSkillType.SuperFast;
- break;
- default:
- msg.MessageOfCharacter.ActiveSkillType = Communication.Proto.ActiveSkillType.NullActiveSkillType;
- break;
- }
-
- switch (player.BulletOfPlayer)
- {
- case Preparation.Utility.BulletType.AtomBomb:
- msg.MessageOfCharacter.BulletType = Communication.Proto.BulletType.AtomBomb;
- break;
- case Preparation.Utility.BulletType.OrdinaryBullet:
- msg.MessageOfCharacter.BulletType = Communication.Proto.BulletType.OrdinaryBullet;
- break;
- case Preparation.Utility.BulletType.FastBullet:
- msg.MessageOfCharacter.BulletType = Communication.Proto.BulletType.FastBullet;
- break;
- case Preparation.Utility.BulletType.LineBullet:
- msg.MessageOfCharacter.BulletType = Communication.Proto.BulletType.LineBullet;
- break;
- default:
- msg.MessageOfCharacter.BulletType = Communication.Proto.BulletType.NullBulletType;
- break;
- }
-
- return msg;
- }
-
- private static MessageToClient.Types.GameObjMessage Bullet(Bullet bullet)
- {
- MessageToClient.Types.GameObjMessage msg = new MessageToClient.Types.GameObjMessage();
- msg.MessageOfBullet = new MessageOfBullet();
- msg.MessageOfBullet.FacingDirection = bullet.FacingDirection;
- msg.MessageOfBullet.Guid = bullet.ID;
- msg.MessageOfBullet.BombRange = BulletFactory.BulletBombRange(bullet.TypeOfBullet);
- switch (bullet.TypeOfBullet)
- {
- case Preparation.Utility.BulletType.AtomBomb:
- msg.MessageOfBullet.Type = Communication.Proto.BulletType.AtomBomb;
- break;
- case Preparation.Utility.BulletType.OrdinaryBullet:
- msg.MessageOfBullet.Type = Communication.Proto.BulletType.OrdinaryBullet;
- break;
- case Preparation.Utility.BulletType.FastBullet:
- msg.MessageOfBullet.Type = Communication.Proto.BulletType.FastBullet;
- break;
- case Preparation.Utility.BulletType.LineBullet:
- msg.MessageOfBullet.Type = Communication.Proto.BulletType.LineBullet;
- break;
- default:
- msg.MessageOfBullet.Type = Communication.Proto.BulletType.NullBulletType;
- break;
- }
- msg.MessageOfBullet.X = bullet.Position.x;
- msg.MessageOfBullet.Y = bullet.Position.y;
- if (bullet.Parent != null)
- msg.MessageOfBullet.ParentTeamID = bullet.Parent.TeamID;
- switch (bullet.Place)
- {
- case Preparation.Utility.PlacccceType.Land:
- msg.MessageOfBullet.Place = Communication.Proto.PlacccceType.Land;
- break;
- case Preparation.Utility.PlacccceType.Grass1:
- msg.MessageOfBullet.Place = Communication.Proto.PlacccceType.Grass1;
- break;
- case Preparation.Utility.PlacccceType.Grass2:
- msg.MessageOfBullet.Place = Communication.Proto.PlacccceType.Grass2;
- break;
- case Preparation.Utility.PlacccceType.Grass3:
- msg.MessageOfBullet.Place = Communication.Proto.PlacccceType.Grass3;
- break;
- default:
- msg.MessageOfBullet.Place = Communication.Proto.PlacccceType.NullPlaceType;
- break;
- }
- return msg;
- }
-
- private static MessageToClient.Types.GameObjMessage Prop(Prop prop)
- {
- MessageToClient.Types.GameObjMessage msg = new MessageToClient.Types.GameObjMessage();
- msg.MessageOfProp = new MessageOfProp();
- msg.MessageOfProp.FacingDirection = prop.FacingDirection;
- msg.MessageOfProp.Guid = prop.ID;
- msg.MessageOfProp.IsMoving = prop.IsMoving;
- switch (prop.GetPropType())
- {
- case Preparation.Utility.PropType.Gem:
- msg.MessageOfProp.Type = Communication.Proto.PropType.Gem;
- break;
- case Preparation.Utility.PropType.addLIFE:
- msg.MessageOfProp.Type = Communication.Proto.PropType.AddLife;
- break;
- case Preparation.Utility.PropType.addSpeed:
- msg.MessageOfProp.Type = Communication.Proto.PropType.AddSpeed;
- break;
- case Preparation.Utility.PropType.Shield:
- msg.MessageOfProp.Type = Communication.Proto.PropType.Shield;
- break;
- case Preparation.Utility.PropType.Spear:
- msg.MessageOfProp.Type = Communication.Proto.PropType.Spear;
- break;
- default:
- msg.MessageOfProp.Type = Communication.Proto.PropType.NullPropType;
- break;
- }
- msg.MessageOfProp.X = prop.Position.x;
- msg.MessageOfProp.Y = prop.Position.y;
- if(prop is Gem)
- {
- msg.MessageOfProp.Size = ((Gem)prop).Size;
- }
- else
- {
- msg.MessageOfProp.Size = 1;
- }
- switch (prop.Place)
- {
- case Preparation.Utility.PlacccceType.Land:
- msg.MessageOfProp.Place = Communication.Proto.PlacccceType.Land;
- break;
- case Preparation.Utility.PlacccceType.Grass1:
- msg.MessageOfProp.Place = Communication.Proto.PlacccceType.Grass1;
- break;
- case Preparation.Utility.PlacccceType.Grass2:
- msg.MessageOfProp.Place = Communication.Proto.PlacccceType.Grass2;
- break;
- case Preparation.Utility.PlacccceType.Grass3:
- msg.MessageOfProp.Place = Communication.Proto.PlacccceType.Grass3;
- break;
- default:
- msg.MessageOfProp.Place = Communication.Proto.PlacccceType.NullPlaceType;
- break;
- }
- return msg;
- }
-
- private static MessageToClient.Types.GameObjMessage BombedBullet(BombedBullet bombedBullet)
- {
- MessageToClient.Types.GameObjMessage msg = new MessageToClient.Types.GameObjMessage();
- msg.MessageOfBombedBullet = new MessageOfBombedBullet();
-
- msg.MessageOfBombedBullet.FacingDirection = bombedBullet.bulletHasBombed.FacingDirection;
- msg.MessageOfBombedBullet.X = bombedBullet.bulletHasBombed.Position.x;
- msg.MessageOfBombedBullet.Y = bombedBullet.bulletHasBombed.Position.y;
- msg.MessageOfBombedBullet.MappingID = bombedBullet.MappingID;
- msg.MessageOfBombedBullet.BombRange = BulletFactory.BulletBombRange(bombedBullet.bulletHasBombed.TypeOfBullet);
- switch (bombedBullet.bulletHasBombed.TypeOfBullet)
- {
- case Preparation.Utility.BulletType.OrdinaryBullet:
- msg.MessageOfBombedBullet.Type = Communication.Proto.BulletType.OrdinaryBullet;
- break;
- case Preparation.Utility.BulletType.AtomBomb:
- msg.MessageOfBombedBullet.Type = Communication.Proto.BulletType.AtomBomb;
- break;
- case Preparation.Utility.BulletType.FastBullet:
- msg.MessageOfBombedBullet.Type = Communication.Proto.BulletType.FastBullet;
- break;
- case Preparation.Utility.BulletType.LineBullet:
- msg.MessageOfBombedBullet.Type = Communication.Proto.BulletType.LineBullet;
- break;
- default:
- msg.MessageOfBombedBullet.Type = Communication.Proto.BulletType.NullBulletType;
- break;
- }
- return msg;
- }
-
- private static MessageToClient.Types.GameObjMessage PickedProp(PickedProp pickedProp)
- {
- MessageToClient.Types.GameObjMessage msg = new MessageToClient.Types.GameObjMessage();
- msg.MessageOfPickedProp = new MessageOfPickedProp();
-
- msg.MessageOfPickedProp.MappingID = pickedProp.MappingID;
- msg.MessageOfPickedProp.X = pickedProp.PropHasPicked.Position.x;
- msg.MessageOfPickedProp.Y = pickedProp.PropHasPicked.Position.y;
- msg.MessageOfPickedProp.FacingDirection = pickedProp.PropHasPicked.FacingDirection;
- switch (pickedProp.PropHasPicked.GetPropType())
- {
- case Preparation.Utility.PropType.Gem:
- msg.MessageOfPickedProp.Type = Communication.Proto.PropType.Gem;
- break;
- case Preparation.Utility.PropType.addLIFE:
- msg.MessageOfPickedProp.Type = Communication.Proto.PropType.AddLife;
- break;
- case Preparation.Utility.PropType.addSpeed:
- msg.MessageOfPickedProp.Type = Communication.Proto.PropType.AddSpeed;
- break;
- case Preparation.Utility.PropType.Shield:
- msg.MessageOfPickedProp.Type = Communication.Proto.PropType.Shield;
- break;
- case Preparation.Utility.PropType.Spear:
- msg.MessageOfPickedProp.Type = Communication.Proto.PropType.Spear;
- break;
- default:
- msg.MessageOfPickedProp.Type = Communication.Proto.PropType.NullPropType;
- break;
- }
- return msg;
- }
- }
- }*/
- // 等Preparation完成再写
|