示例#1
0
        public void Update(Camera camera, Character character)
        {
            AquaticPhysics.Instance.DynamicsWorld.StepSimulation(GameModel.GlobalElapsedTime);

            var toUpdate = ToUpdate(camera.Position);

            renderedOrigins = toUpdate.ConvertAll(chunk => chunk.Origin).FindAll(v3 => v3.Y / (Chunk.DefaultSize.Y) == Chunk.seaFloor);

            var elements   = new List <Element>();
            var updateCube = new Cube(camera.Position, (int)Math.Floor((UpdateRadius + 1) * Chunk.DefaultSize.X));

            var allElements = new List <Element>();

            elements.AddRange(elementsInCube(this.entities, updateCube));
            //elements.AddRange(elementsInCube(toUpdate.SelectMany(chunk => chunk.Elements).ToList(), updateCube));

            elements.ForEach(element => element.Update(camera));
            toUpdate.ForEach(chunk => chunk.Update(camera));

            elementsToUpdate = elements;

            shark.Update(camera, character);

            this.elementsUpdated = elements.Count;

            allElements.AddRange(elements);
            allElements.AddRange(elementsInCube(toUpdate.SelectMany(chunk => chunk.Elements).ToList(), updateCube));

            SelectableElement = GetSelectableElement(camera, allElements);
        }
示例#2
0
        public void Remove(Element selectableElement)
        {
            entities.Remove(selectableElement);

            foreach (var chunk in chunks.Values)
            {
                chunk.Remove(selectableElement);
            }
        }
        private IItem manageSelectableElement(Element element)
        {
            if (element == null)
            {
                dialogName = dialogDescription = "";
                cursor     = aim;
                return(null);
            }

            cursor = hand;
            IItem item = null;

            if (element.item != null)
            {
                if (element.item.Name != dialogName)
                {
                    dialogBox.Open();
                }
                dialogName        = element.item.Name;
                dialogDescription = element.item.Description;
            }

            if (element.GetType() == typeof(Ship))
            {
                if ("Ship" != dialogName)
                {
                    dialogBox.Open();
                }
                dialogName        = "Ship";
                dialogDescription = "Enter to the ship";
            }

            element.Selectable = true;

            if (aimFired)
            {
                if (element.GetType() == typeof(Ship))
                {
                    onGetIntoShipCallback(GameState);
                }
                else
                {
                    var toPlay = element.GetType() == typeof(Coral) ? SoundManager.Coral : SoundManager.Bubble;
                    SoundManager.Play(toPlay);
                    World.Remove(element);
                    item     = element.item;
                    aimFired = false;
                }
            }

            return(item);
        }