Esempio n. 1
0
        /// <summary>
        /// Checks for collision with a object.
        /// A collision with a unfriendly laser or another enemy ship will not cause its destruction.
        /// </summary>
        /// <param name="anotherObserver">Another observer.</param>
        /// <param name="elapsedGameTime">The elapsed game time.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public override bool CheckForCollisionWith(IGameObjectObserver anotherObserver, TimeSpan elapsedGameTime)
        {
            GAME_OBJECT_TYPE otherType = anotherObserver.GetObserved().ObjectType;

            if (otherType == GAME_OBJECT_TYPE.UNFRIENDLY_LASER || otherType == GAME_OBJECT_TYPE.ENEMY_SHIP) return false;
            return collisionSphere.Intersects(anotherObserver.GetObserved().CollisionSphere);
        }
Esempio n. 2
0
 /// <summary>
 /// Adds a new observer to the list.
 /// </summary>
 /// <param name="observer">The observer.</param>
 public void AddObserver(IGameObjectObserver observer)
 {
     if (!observers.Contains(observer))
     {
         observers.Add(observer);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Adds points to the score, depending on what was destroyed and if the x2 multiplier is activated.
        /// </summary>
        /// <param name="destroyedObjectObserver">The destroyed object observer.</param>
        /// <param name="elapsedGameTime">The elapsed game time.</param>
        public override void AddPoints(IGameObjectObserver destroyedObjectObserver, TimeSpan elapsedGameTime)
        {
            if (doublePoints)
            {
                if (lastTimePowerUpActivated == null || elapsedGameTime - lastTimePowerUpActivated >= X2_DURRATION)
                    doublePoints = false;
            }

            scoreBoard.AddPoints(destroyedObjectObserver.GetObserved(), doublePoints);
        }
Esempio n. 4
0
        /// <summary>
        /// Checks for collision with another object. Only activate the power up if the hitter is a player or a friendly bullet
        /// </summary>
        /// <param name="anotherObserver">Another observer.</param>
        /// <param name="elapsedGameTime">The elapsed game time.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public override bool CheckForCollisionWith(IGameObjectObserver anotherObserver, TimeSpan elapsedGameTime)
        {
            GAME_OBJECT_TYPE otherType = anotherObserver.GetObserved().ObjectType;
            if (otherType == GAME_OBJECT_TYPE.PLAYER || otherType == GAME_OBJECT_TYPE.FRIENDLY_LASER)
            {
                ActivatePowerUp(elapsedGameTime);
                return collisionSphere.Intersects(anotherObserver.GetObserved().CollisionSphere);

            }
            return false;
        }
Esempio n. 5
0
        public ClientConnectionHolder(IGameObjectObserver client, Guid clientId, IGameObjectSelfAccessor parent)
        {
            _working      = true;
            _client       = client;
            _parent       = parent;
            _messageQueue = new Queue <JediumBehaviourMessage[]>();
            _clientId     = clientId;

            _client.GotAddress();
            // Self.Tell(new ResendMessage(),null);
            Context.System.Scheduler.ScheduleTellRepeatedly(TimeSpan.FromSeconds(0), TimeSpan.FromMilliseconds(MainSettings.TickDelay), Self, _tick, ActorRefs.NoSender);
        }
Esempio n. 6
0
        async Task IGameObject.RegisterClient(Guid clientid, IGameObjectObserver client)
        {
            _log.Info("Registering client:" + clientid);

            if (_clients.ContainsKey(clientid))
            {
                _log.Error("Client with this id already exists!");
            }
            else
            {
                _clients.Add(clientid, client);
            }
        }
Esempio n. 7
0
        Task IGameObject.RegisterClient(Guid clientid, IGameObjectObserver client)
        {
            _log.Info("Registering client:" + clientid);

            if (_clients.ContainsKey(clientid))
            {
                _log.Error("Client with this id already exists!");
            }
            else
            {
                var holder = Context.ActorOf(Props.Create(() => new ClientConnectionHolder(client, clientid, this)))
                             .Cast <ClientConnectionHolderRef>();
                _clients.Add(clientid, holder);
            }

            return(Task.FromResult(true));
        }
Esempio n. 8
0
        public override bool CheckForCollisionWith(IGameObjectObserver anotherObserver, TimeSpan elapsedGameTime)
        {
            if (anotherObserver.GetObserved().ObjectType == GAME_OBJECT_TYPE.POWER_UP) return false;

            if (anotherObserver.GetObserved().ObjectType == GAME_OBJECT_TYPE.ASTEROID)
            {
                if (currentSize != Size.LARGE && ((Asteroid)anotherObserver.GetObserved()).CurrentSize == currentSize && anotherObserver != this && CanMerge(elapsedGameTime))
                {
                    return collisionSphere.Intersects(anotherObserver.GetObserved().CollisionSphere);
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return collisionSphere.Intersects(anotherObserver.GetObserved().CollisionSphere);
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Removes a observer from the list.
 /// </summary>
 /// <param name="observer">The observer.</param>
 public void RemoveObserver(IGameObjectObserver observer)
 {
     if (observers.Contains(observer))
     {
         observers.Remove(observer);
     }
 }
Esempio n. 10
0
 /// <summary>
 /// Adds points to  the score, only used in childrens
 /// </summary>
 /// <param name="destroyedObjectObserver">The destroyed object observer.</param>
 /// <param name="elapsedGameTime">The elapsed game time.</param>
 /// <exception cref="NotImplementedException"></exception>
 public virtual void AddPoints(IGameObjectObserver destroyedObjectObserver, TimeSpan elapsedGameTime)
 {
     throw new NotImplementedException();
 }
Esempio n. 11
0
 /// <summary>
 /// Sets the hitter.
 /// </summary>
 /// <param name="subject">The subject.</param>
 /// <param name="hitter">The hitter.</param>
 public void SetHitter(Subject subject, IGameObjectObserver hitter)
 {
     subject.Hitter = hitter;
 }
Esempio n. 12
0
 /// <summary>
 /// Checks for collision with a object.
 /// </summary>
 /// <param name="anotherGameObject">Another game object.</param>
 /// <param name="elapsedGameTime">The elapsed game time.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 public virtual bool CheckForCollisionWith(IGameObjectObserver anotherGameObject, TimeSpan elapsedGameTime)
 {
     return false;
 }
Esempio n. 13
0
 /// <summary>
 /// Adds points to score by passing a observer that observe a game object.
 /// </summary>
 /// <param name="subject">The subject.</param>
 /// <param name="destroyedObjectObserver">The destroyed object observer.</param>
 /// <exception cref="NotImplementedException"></exception>
 public void AddPoints(Subject subject, IGameObjectObserver destroyedObjectObserver)
 {
     throw new NotImplementedException();
 }
Esempio n. 14
0
 /// <summary>
 /// Checks for collision with a object.
 /// </summary>
 /// <param name="anotherGameObject">Another game object.</param>
 /// <param name="elapsedGameTime">The elapsed game time.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 public override bool CheckForCollisionWith(IGameObjectObserver anotherGameObject, TimeSpan elapsedGameTime)
 {
     return collisionSphere.Intersects(anotherGameObject.GetObserved().CollisionSphere);
 }
Esempio n. 15
0
        /// <summary>
        /// Checks for collision with a object.
        /// </summary>
        /// <param name="anotherObserver">Another observer.</param>
        /// <param name="elapsedGameTime">The elapsed game time.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public override bool CheckForCollisionWith(IGameObjectObserver anotherObserver, TimeSpan elapsedGameTime)
        {
            GAME_OBJECT_TYPE anotherObjectType = anotherObserver.GetObserved().ObjectType;

            if (anotherObjectType != GAME_OBJECT_TYPE.FRIENDLY_LASER &&
                anotherObjectType != GAME_OBJECT_TYPE.POWER_UP &&
                anotherObjectType != GAME_OBJECT_TYPE.PLAYER)
            {
                if (collisionSphere.Intersects(anotherObserver.GetObserved().CollisionSphere)) return true;

            }
            return false;
        }
Esempio n. 16
0
 Task IGameObject.RegisterClient(Guid clientId, IGameObjectObserver client)
 {
     _log.Error(".RegisterClient() should not be called on client!");
     return(Task.FromResult(false));
 }