Esempio n. 1
0
        public void OnServerRelease(IGrabbable grabbable, CameraInfo cameraInfo, Player player)
        {
            if (this.Delegate == null)
            {
                throw new Exception("No Delegate");
            }

            if (grabbable is Catapult catapult)
            {
                // Launch the ball
                var velocity = catapult.TryGetLaunchVelocity(cameraInfo);
                if (velocity != null)
                {
                    catapult.OnLaunch(velocity);
                    this.SlingBall(catapult, velocity);
                    catapult.ReleaseSlingGrab();

                    this.ReleaseCatapultGrab(catapult.CatapultId);

                    var slingData = new SlingData(catapult.CatapultId, catapult.ProjectileType, velocity);

                    // succeed in launching catapult, notify all clients of the update
                    this.Delegate.ServerDispatchActionToAll(new GameActionType {
                        CatapultRelease = slingData, Type = GameActionType.GActionType.CatapultRelease
                    });
                }
            }
        }
Esempio n. 2
0
 private void HandleCatapultReleaseAction(SlingData data, Player player, IInteractionDelegate @delegate)
 {
     if (this.catapults.TryGetValue(data.CatapultId, out Catapult catapult))
     {
         catapult.OnLaunch(GameVelocity.Zero);
         this.ReleaseCatapultGrab(data.CatapultId);
     }
 }