Beispiel #1
0
        public void Handle(GameActionType gameAction, Player player)
        {
            if (this.Delegate == null)
            {
                throw new Exception("No Delegate");
            }

            if (gameAction.Type == GameActionType.GActionType.HitCatapult)
            {
                var catapult = this.Delegate.Catapults.FirstOrDefault(item => item.CatapultId == gameAction.CatapultKnockOut.CatapultId);
                if (catapult != null)
                {
                    if (!catapult.Disabled)
                    {
                        catapult.ProcessKnockOut(gameAction.CatapultKnockOut);
                        catapult.IsGrabbed = false;
                    }
                }
            }
            else if (gameAction.Type == GameActionType.GActionType.KnockoutSync && this.Delegate.IsServer)
            {
                // Server will dispatch catapult knockout messages to all clients to make sure knockout states are in sync
                foreach (var catapult in this.Delegate.Catapults.Where(catapult => catapult.Disabled))
                {
                    var knockoutInfo = new HitCatapult(catapult.CatapultId, false, false);
                    this.Delegate.DispatchActionToAll(new GameActionType {
                        CatapultKnockOut = knockoutInfo, Type = GameActionType.GActionType.HitCatapult
                    });
                }
            }
        }
Beispiel #2
0
        public void ProcessKnockOut(HitCatapult knockoutInfo)
        {
            // hide the ball and strap
            this.strapVisible = StrapVisible.Hidden;
            this.BallVisible  = BallVisible.Hidden;
            this.Disabled     = true;

            // Remove everything except catpault base/prong
            this.Delegate?.DidBreak(this, knockoutInfo.JustKnockedout, knockoutInfo.Vortex);
        }
Beispiel #3
0
        public void VortexDidActivate(VortexInteraction vortex)
        {
            // Kill all catapults when vortex activates
            if (this.Delegate == null)
            {
                throw new Exception("No delegate");
            }

            foreach (var catapult in this.catapults.Values)
            {
                var data = new HitCatapult(catapult.CatapultId, false, true);
                this.Delegate.DispatchActionToAll(new GameActionType {
                    CatapultKnockOut = data, Type = GameActionType.GActionType.HitCatapult
                });
            }
        }
Beispiel #4
0
        public void Update(CameraInfo cameraInfo)
        {
            if (this.Delegate == null)
            {
                throw new Exception("No Delegate");
            }

            foreach (var catapult in this.Delegate.Catapults)
            {
                // Check and disable knocked catapults
                if (!catapult.Disabled && catapult.CatapultKnockedTime > CatapultUnstableTimeUntilDisable)
                {
                    var knockoutInfo = new HitCatapult(catapult.CatapultId, true, false);
                    this.Delegate.DispatchActionToAll(new GameActionType {
                        CatapultKnockOut = knockoutInfo, Type = GameActionType.GActionType.HitCatapult
                    });
                }
            }
        }