Example #1
0
        protected void BoatIslandCollision(Boat boat, Island island)
        {
            if (boat.Colour == island.Colour)        // island matches boat colour
            {
                if (boat.CarriedResources.Count > 0) // if carrying a resource
                {
                    // plays the collect resource sound. This should maybe be in the CollectResource method
                    scoreCargo.Play();

                    // collect all carried resources
                    foreach (var resource in boat.CarriedResources)
                    {
                        PlayersByColour[(int)boat.Colour].CollectResource(resource);
                        island.AddToken(Token.Copy(PlayersByColour[(int)resource.Colour].Island.TokenType));
                    }
                    boat.CarriedResources.Clear();
                }
            }
            else // island does not match boat colour
            {
                // retrieve resource if allowed
                if (!boat.CarriesResource(island.ResourceType) && (boat.CarriedResources.Count == 0 || BOATS_CARRY_MULTIPLE_RESOURCES))
                {
                    takeCargo.Play(); // play the sound
                    PlayersByColour[(int)island.Colour].Score -= 200;
                    Resource resource = Resource.Copy(island.ResourceType);
                    resource.IsCarried = true;
                    resource.Position  = boat.Position;
                    boat.CarriedResources.Add(resource);
                }
            }
        }