コード例 #1
0
    /// <summary>
    /// Collision checker that checks for collisions with interactive objects
    /// </summary>
    private void InteractCollisionChecker()
    {
        // Code that handles a player trying to revive his friend
        GameObjectList charList = GameWorld.Find("playerLIST") as GameObjectList;

        foreach (Character c in charList.Children)
        {
            if (this.CollidesWith(c) && c.IsDowned)
            {
                if (reviveTimer.IsPaused)
                {
                    reviveTimer.Reset();
                }
                else if (reviveTimer.IsExpired)
                {
                    c.attributes.HP      = c.baseattributes.HP;
                    reviveTimer.IsPaused = true;
                }
            }
        }

        GameObjectList objectList = GameWorld.Find("objectLIST") as GameObjectList;

        // If a character collides with an interactive object, set the target character to this instance and tell the interactive object that it is currently interacting
        foreach (var intObj in objectList.Children)
        {
            if (intObj is InteractiveObject)
            {
                InteractiveObject intObj_cast = intObj as InteractiveObject;
                if (intObj_cast.CollidesWith(this))
                {
                    intObj_cast.TargetCharacter = this;
                    intObj_cast.IsInteracting   = true;
                    // if the intobj is a key set hasakey to true
                    if (intObj is KeyItem)
                    {
                        HasAKey = true;
                    }
                }
            }
        }
    }