Exemple #1
0
        public override void FinishAction()
        {
            TileBehaviour.OnMove = false;
            var remoteMethod = new RemoteInvokeMethod("BoardBehavior", Command.FinishAction);

            BeginSendPackage(remoteMethod);
        }
Exemple #2
0
        public override void DefenseCreature(CreatureComponent creature)
        {
            var parameters = new List <SerializableType> {
                creature.Piece.Location
            };
            var remoteMethod = new RemoteInvokeMethod("BoardBehavior", Command.Defend, parameters);

            BeginSendPackage(remoteMethod);
        }
        void Awake()
        {
            ExecuteOnMainThread       = new Queue <Action>();
            _creatureHelper           = GameObject.Find("GameManager").GetComponent <CreatureHelper>();
            _player                   = Networking.Network.Instance.ClientPlayer;
            _creatureHelper.Creatures = new List <AbstractCreature>();

            MustAttack = false;
            _canMove   = false;

            GameFlow.Instance.Channel = new NetworkMessageChannel(_player);
            GameFlow.Instance.Channel.MoveCallback        += DrawPath;
            GameFlow.Instance.Channel.TurnCallback        += ChangeTurn;
            GameFlow.Instance.Channel.SyncHeroesCallback  += SyncHero;
            GameFlow.Instance.Channel.Attack              += Attack;
            GameFlow.Instance.Channel.GameIsReadyCallback += GameIsReady;
            GameFlow.Instance.Channel.DieCallback         += Die;
            GameFlow.Instance.Channel.FinishGame          += FinishGame;

            Messenger <TileBehaviour> .AddListener("Tile selected", MoveCreatureToSelectedTile);

            Messenger <CreatureComponent> .AddListener("Action finish", FinishAction);

            Messenger <CreatureComponent> .AddListener("CreatureComponent Selected", MouseOverCreature);

            Messenger <CreatureComponent> .AddListener("CreatureComponent Exit", MouseExitCreature);

            Messenger <CreatureComponent> .AddListener("CreatureComponent Attack", MouseClickCreature);

            _hero1Obj = Instantiate(Hero1Prefab) as GameObject;
            _hero2Obj = Instantiate(Hero2Prefab) as GameObject;

            _prefabCollector = PrefabDatabase.GetComponent <PrefabCollector>();

            _creaturePrefabDictionary.Add("Marksman", "GoblinHex");
            _creaturePrefabDictionary.Add("Troglodyte", "OrcHex");

            _creatureHelper.PlayerLeft.text  = GameFlow.Instance.PlayerLeftName;
            _creatureHelper.PlayerRight.text = GameFlow.Instance.PlayerRightName;

            _imageDictionary = new Dictionary <NetworkTypes.CreatureType, Sprite>()
            {
                { NetworkTypes.CreatureType.Range, _prefabCollector.CreatureImages.SingleOrDefault(x => x.Name == "Range").Image },
                { NetworkTypes.CreatureType.Melee, _prefabCollector.CreatureImages.SingleOrDefault(x => x.Name == "Melee").Image }
            };

            var roomName = new SimpleMessage {
                Message = GameFlow.Instance.RoomName
            };
            var parameters = new List <SerializableType> {
                roomName
            };
            var remoteInvokeMethod = new RemoteInvokeMethod("", Command.InitializeBoard, parameters);

            Client.BeginSendPackage(remoteInvokeMethod);
        }
Exemple #4
0
        public override void MovePiece(Point start, Point destination)
        {
            TileBehaviour.OnMove = true;
            var parameters = new List <SerializableType> {
                start, destination
            };
            var remoteMethod = new RemoteInvokeMethod("BoardBehavior", Command.Move, parameters);

            BeginSendPackage(remoteMethod);
        }
Exemple #5
0
        public override void AttackCreature(int targetIndex, int creatureIndex)
        {
            var args = new List <SerializableType>
            {
                new AttackModel()
                {
                    TargetCreatureIndex = targetIndex,
                    SenderCreatureIndex = creatureIndex,
                    Damage = 0
                }
            };
            var remoteMethod = new RemoteInvokeMethod("BoardBehavior", Command.Attack, args);

            BeginSendPackage(remoteMethod);
        }
Exemple #6
0
    public void Start()
    {
        ExecuteOnMainThread = new Queue <Action>();

        if (Assets.Scripts.Networking.Network.Instance.ClientPlayer == null)
        {
            return;
        }
        GameFlow.Instance.IsGameCreator = false;
        GameFlow.Instance.RoomName      = "";
        var remoteMethod = new RemoteInvokeMethod("BoardBehavior", Command.GetLobbies);
        var bytes        = RemoteInvokeMethod.WriteToStream(remoteMethod);

        Assets.Scripts.Networking.Network.Instance.Client.Send(bytes, bytes.Length, 0);
    }
Exemple #7
0
        private static void BeginSendPackage(RemoteInvokeMethod remoteMethod)
        {
            var bytes = RemoteInvokeMethod.WriteToStream(remoteMethod);

            Network.Instance.Client.Send(bytes, bytes.Length, 0);
        }