Example #1
0
        public Macedonia(Vector3 position, float orientation)
            : base("macedonia", position, orientation, 4)
        {
            life = LIFE;
            idleTime = 0;
            changeState(tMacedoniaBossState.Init);

            lifebar = new Lifebar("macedonia", this, new Vector2(0.6f, 0.6f), new Vector2(0.0f, 170.0f), Color.White);

            for(int i=0; i<MAX_RAYOS; i++)
            {
                rayo[i] = new AnimatedEntity2D("animatedProps", "macedoniaWeaponBody", Vector3.Zero, 0, Color.White);
                //rayo[i].scale = new Vector3(rayo[i].scale.X * 2, rayo[i].scale.Y, rayo[i].scale.Z);
            }
            rayoEnd = new AnimatedEntity2D("animatedProps", "macedoniaWeaponEnd", Vector3.Zero, 0, Color.White);
            //rayoEnd.scale = new Vector3(rayoEnd.scale.X * 2, rayoEnd.scale.Y, rayoEnd.scale.Z);

            showRayo(false);

            visible = false;

            //scale *= 2;

            loadIntroCinematic();
            //loadEndCinematic();
        }
 public void loadEntity(int index)
 {
     #if EDITOR
     var textures = SB.content.LoadContent("xml/animatedProps");
     currentIndex = (index + textures.Count) % textures.Count;
     Vector3 position = Camera2D.position;
     position.Z = 0.0f;
     AnimatedEntity2D ent = new AnimatedEntity2D("animatedProps", textures[currentIndex], position, 0, Color.White);
     LevelManager.Instance.addAnimatedProp(ent);
     entity = ent;
     #endif
 }
        public DialogEvent(tDialogCharacter character, string text, AnimatedEntity2D entity = null, float activationTime = 0.3f, float textSpeed = 30.0f, bool skippable = true)
            : base(activationTime)
        {
            this.character = character;
            this.text = text;
            this.textSpeed = textSpeed;
            this.entity = entity;

            this.textComplete = false;
            this.charactersToShow = 0;

            this.skippable = skippable;
        }
        public override void initialize()
        {
            base.initialize();

            CameraManager.Instance.cameraMode = CameraManager.tCameraMode.None;
            Camera2D.position = new Vector3(0.0f, 0.0f, 2000.0f);

            //EntityManager.Instance.registerEntity(GamerManager.getGamerEntity(0).Player);
            onionElder = new AnimatedEntity2D("animatedProps", "onionElder", new Vector3(0.0f, 150.0f, 0.0f), 0.0f, Color.White);

            kingTomato = (KingTomato)EnemyManager.Instance.addEnemy("kingTomato", new Vector3(1200.0f, 1000.0f, 0));
            kingTomato.updateState = RenderableEntity2D.tUpdateState.NoUpdate;
            loadIntroCinematic();
            loadSpeechCinematic(kingTomato);
            loadReturnsCinematic();
            CinematicManager.Instance.playCinematic("kingTomatoIntro");

            SoundManager.Instance.playSong("Naughty_song_test3", true);
        }
        public override void loadContent()
        {
            EditorHelper.Instance.loadNewLevelFromGame("intro");
            GamerManager.getMainPlayer().renderState = RenderableEntity2D.tRenderState.NoRender;
            GamerManager.getMainPlayer().mode = Player.tMode.SavingItems;

            foreach (AnimatedEntity2D ent in LevelManager.Instance.getAnimatedProps())
            {
                if (ent.entityName == "ash")
                    ash = ent;
                if (ent.entityName == "ashTears")
                    ashTears = ent;
                if (ash != null && ashTears != null)
                    break;
            }

            ash.playAction("cry");
            ashTears.playAction("tearsLoop");
            ashTears.renderState = RenderableEntity2D.tRenderState.NoRender;
            state = tAshState.Cry;
        }
Example #6
0
        public bool update()
        {
            if (((StateGame)StateManager.getCurrentState()).gameRunning)
            {
                tabControl1.Enabled = false;
                return true;
            }

            if (!tabControl1.Enabled)
                tabControl1.Enabled = true;

            mouseState = Mouse.GetState();
            keyState = Keyboard.GetState();

            System.Drawing.Point point = MyEditor.Instance.myEditorControl.PointToClient(new System.Drawing.Point(MyEditor.Instance.getMouseState().X, MyEditor.Instance.getMouseState().Y));
            gameScreenPos = new Vector2(point.X, point.Y);

            if (noUpdate > 0)
            {
                return true;
            }

            if ( (isKeyPressed(Microsoft.Xna.Framework.Input.Keys.LeftControl) || isKeyPressed(Microsoft.Xna.Framework.Input.Keys.RightControl)) && justPressedKey(Microsoft.Xna.Framework.Input.Keys.Z))
            {
                noUpdate++;
                MessageBox.Show(MyEditor.ActiveForm, "PULSA OK PARA FORMATEAR EL DISCO DURO.", "Control SETA");
                MessageBox.Show(MyEditor.ActiveForm, "FORMATEANDO...", "Control SETA");
                noUpdate--;
            }

            //skip frame f.e. when coming back from load/save dialog
            if (skipFrames > 0)
            {
                skipFrames--;
                return true;
            }

            if (texturesCombo.Focused)
            {
                return true;
            }

            if (currentState == null)
            {
                changeState(new EditorState_MoveState());
            }

            if (nextState != null)
            {
                doChangeState();
            }

            //EXIT
            if(exitBlockers <= 0 && justPressedKey(Microsoft.Xna.Framework.Input.Keys.Escape))
            {
                return false;
            }

            //GRID
            if (justPressedKey(Microsoft.Xna.Framework.Input.Keys.G))
            {
                drawGrid = !drawGrid;
            }
            if (isKeyPressed(Microsoft.Xna.Framework.Input.Keys.H))
            {
                EntityManager.Instance.renderCollisionParts();
            }

            //STATE CHANGE
            else if (justPressedKey(Microsoft.Xna.Framework.Input.Keys.Q))
            {
                changeState(new EditorState_MoveState());
            }
            else if (justPressedKey(Microsoft.Xna.Framework.Input.Keys.W))
            {
                changeState(new EditorState_RotateState());
            }
            else if (justPressedKey(Microsoft.Xna.Framework.Input.Keys.E))
            {
                changeState(new EditorState_ScaleState());
            }
            else if (justPressedKey(Microsoft.Xna.Framework.Input.Keys.B))
            {
                colorButton_Click(null, null);
            }
            else if (justPressedKey(Microsoft.Xna.Framework.Input.Keys.D8))
            {
                CameraManager.Instance.speedMultiplier = 1.0f;
            }
            else if (justPressedKey(Microsoft.Xna.Framework.Input.Keys.D9))
            {
                CameraManager.Instance.speedMultiplier -= 0.5f;
            }
            else if (justPressedKey(Microsoft.Xna.Framework.Input.Keys.D0))
            {
                CameraManager.Instance.speedMultiplier += 0.5f;
            }

            //RESET
            //else if (justPressedKey(Microsoft.Xna.Framework.Input.Keys.R))
            //{
            //    EntityManager.Instance.reset();
            //}

            //MOVE CAMERA
            else if (keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Space) && mouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                Camera2D.position.X -= (mouseState.X - lastMouseState.X) * (Camera2D.position.Z / 1000);
                Camera2D.position.Y += (mouseState.Y - lastMouseState.Y) * (Camera2D.position.Z / 1000);
            }
            else if (keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Space) && mouseState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                //Camera2D.position.Z -= (mouseState.Y - lastMouseState.Y);
                Camera2D.position.Z -= (mouseState.Y - lastMouseState.Y) * (Camera2D.position.Z / 400);
            }
            else if (keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Space))
            {
            }

            //DELETE
            else if (justPressedKey(Microsoft.Xna.Framework.Input.Keys.Delete) && anyEntitySelected())
            {
                foreach (Entity2D ent in selectedEntities)
                {
                    ent.delete();
                }
                selectedEntities.Clear();
            }

            //DUPLICATE
            else if (justPressedKey(Microsoft.Xna.Framework.Input.Keys.D))
            {
                if (anyEntitySelected())
                {
                    List<Entity2D> newEntities = new List<Entity2D>();

                    foreach (RenderableEntity2D ent in selectedEntities)
                    {
                        RenderableEntity2D newEntity = null;
                        if (ent is Enemy)
                        {
                            newEntity = (RenderableEntity2D)EnemyManager.Instance.addEnemy(ent.entityName, ent.position);
                        }
                        else if (ent is AnimatedEntity2D)
                        {
                            newEntity = new AnimatedEntity2D("animatedProps", ent.entityName, ent.position, 0, Color.White);
                            LevelManager.Instance.addAnimatedProp(newEntity);
                        }
                        else if (ent is RenderableEntity2D)
                        {
                            newEntity = new RenderableEntity2D("staticProps", ent.entityName, ent.position, 0, Color.White);
                            LevelManager.Instance.addStaticProp(newEntity);
                        }

                        newEntity.color = ent.color;
                        newEntity.flipHorizontal = ent.flipHorizontal;
                        newEntity.flipVertical = ent.flipVertical;

                        newEntity.worldMatrix = ent.worldMatrix;

                        newEntity.living = ent.living;
                        newEntity.livingIntensityMin = ent.livingIntensityMin;
                        newEntity.livingIntensityMax = ent.livingIntensityMax;
                        newEntity.livingSpeedMin = ent.livingSpeedMin;
                        newEntity.livingSpeedMax = ent.livingSpeedMax;

                        if (newEntity != null)
                        {
                            newEntities.Add(newEntity);
                        }
                    }
                    selectedEntities.Clear();
                    selectedEntities = newEntities;

                    if (selectedEntities.Count > 1)
                        createGroup();
                }
            }

            //UPDATE STATE
            else if (currentState != null)
            {
                currentState.update();
            }

            if (anyEntitySelected())
            {
                currentEntityName.Text = selectedEntities[0].entityName;
            }

            lastMouseState = mouseState;
            lastKeyState = keyState;

            return true;
        }
        // loads the specified file into the editor
        private List<Entity2D> loadLevel(string fileName, bool loadIDs = true)
        {
            // TODO ugly! this must have to be set with the editor and loaded from xml
            if (GamerManager.getMainPlayer() == null)
            {
                GamerManager.createGamerEntity(PlayerIndex.One, true);
            }
            GamerManager.getMainPlayer().mode = Player.tMode.Arcade;

            //fileName = SB.content.RootDirectory + "/xml/levels/" + fileName + ".xml";
            List<Entity2D> list = new List<Entity2D>();
            if (File.Exists(fileName))
            {
                XDocument xml_doc = XDocument.Load(fileName);

                int id;
                IEnumerable<XElement> nodes;

                if (loadIDs)
                {
                    nodes = xml_doc.Descendants("level");
                    XElement levelNode = nodes.First();
                    if (levelNode.Attributes("nextEntityID").Count() > 0)
                    {
                        Entity2D.NEXT_ENTITY_ID = levelNode.Attribute("nextEntityID").Value.toInt();
                    }

                    if (levelNode.Attributes("BGColor").Count() > 0)
                    {
                        SB.BGColor = levelNode.Attribute("BGColor").Value.toColor();
                    }

                    if (levelNode.Attributes("CameraMode").Count() > 0)
                    {
                        CameraManager.Instance.cameraMode = (CameraManager.tCameraMode)Enum.Parse(typeof(CameraManager.tCameraMode), levelNode.Attribute("CameraMode").Value, true);
                    }
                }

                // read static props
                nodes = xml_doc.Descendants("staticProp");
                foreach (XElement node in nodes)
                {
                    id = -1;
                    if (loadIDs && node.Attributes("id").Count() > 0) id = node.Attribute("id").Value.toInt();
                    RenderableEntity2D re = new RenderableEntity2D("staticProps", node.Attribute("entityName").Value, Vector3.Zero, 0, Color.White, true, id);
                    re.worldMatrix = node.Attribute("worldMatrix").Value.toMatrix();
                    if (re.worldMatrix.AnyNanCoord())
                        continue;

                    if (node.Attributes("color").Count() > 0)
                    {
                        re.color = node.Attribute("color").Value.toColor();
                    }
                    if (node.Attributes("flipH").Count() > 0)
                    {
                        re.flipHorizontal = node.Attribute("flipH").Value.toBool();
                        re.flipVertical = node.Attribute("flipV").Value.toBool();
                    }
                    if (node.Attributes("living").Count() > 0)
                    {
                        re.living = node.Attribute("living").Value.toBool();
                    }
                    if (node.Attributes("livingIntensityMin").Count() > 0)
                    {
                        re.livingIntensityMin = node.Attribute("livingIntensityMin").Value.toFloat();
                        re.livingIntensityMax = node.Attribute("livingIntensityMax").Value.toFloat();
                        re.livingSpeedMin = node.Attribute("livingSpeedMin").Value.toFloat();
                        re.livingSpeedMax = node.Attribute("livingSpeedMax").Value.toFloat();
                    }

                    LevelManager.Instance.addStaticProp(re);
                    re.setInit();
                    list.Add(re);
                }

                // read animated props
                nodes = xml_doc.Descendants("animatedProp");
                foreach (XElement node in nodes)
                {
                    id = -1;
                    if (loadIDs && node.Attributes("id").Count() > 0) id = node.Attribute("id").Value.toInt();
                    AnimatedEntity2D ae = new AnimatedEntity2D("animatedProps", node.Attribute("entityName").Value, Vector3.Zero, 0, Color.White, true, id);
                    ae.worldMatrix = node.Attribute("worldMatrix").Value.toMatrix();
                    if (ae.worldMatrix.AnyNanCoord())
                        continue;
                    if (node.Attributes("color").Count() > 0)
                    {
                        ae.color = node.Attribute("color").Value.toColor();
                    }
                    if (node.Attributes("flipH").Count() > 0)
                    {
                        ae.flipHorizontal = node.Attribute("flipH").Value.toBool();
                        ae.flipVertical = node.Attribute("flipV").Value.toBool();
                    }
                    if (node.Attributes("living").Count() > 0)
                    {
                        ae.living = node.Attribute("living").Value.toBool();
                    }
                    if (node.Attributes("livingIntensityMin").Count() > 0)
                    {
                        ae.livingIntensityMin = node.Attribute("livingIntensityMin").Value.toFloat();
                        ae.livingIntensityMax = node.Attribute("livingIntensityMax").Value.toFloat();
                        ae.livingSpeedMin = node.Attribute("livingSpeedMin").Value.toFloat();
                        ae.livingSpeedMax = node.Attribute("livingSpeedMax").Value.toFloat();
                    }

                    LevelManager.Instance.addAnimatedProp(ae);
                    ae.setInit();
                    list.Add(ae);
                }

                // read enemies
                nodes = xml_doc.Descendants("enemy");
                foreach (XElement node in nodes)
                {
                    id = -1;
                    if (loadIDs && node.Attributes("id").Count() > 0) id = node.Attribute("id").Value.toInt();
                    string name = node.Attribute("entityName").Value;
                    Matrix world = node.Attribute("worldMatrix").Value.toMatrix();
                    if (world.AnyNanCoord())
                        continue;
                    RenderableEntity2D e = (RenderableEntity2D)EnemyManager.Instance.addEnemy(name, world.Translation, id);
                    if (node.Attributes("color").Count() > 0)
                    {
                        e.color = node.Attribute("color").Value.toColor();
                    }
                    if (node.Attributes("flipH").Count() > 0)
                    {
                        e.flipHorizontal = node.Attribute("flipH").Value.toBool();
                        e.flipVertical = node.Attribute("flipV").Value.toBool();
                    }

                    if (node.Attributes("living").Count() > 0)
                    {
                        e.living = node.Attribute("living").Value.toBool();
                    }
                    if (node.Attributes("livingIntensityMin").Count() > 0)
                    {
                        e.livingIntensityMin = node.Attribute("livingIntensityMin").Value.toFloat();
                        e.livingIntensityMax = node.Attribute("livingIntensityMax").Value.toFloat();
                        e.livingSpeedMin = node.Attribute("livingSpeedMin").Value.toFloat();
                        e.livingSpeedMax = node.Attribute("livingSpeedMax").Value.toFloat();
                    }

                    e.setInit();
                    list.Add(e);
                }

                //Enemy spaws zones
                nodes = xml_doc.Descendants("enemySpawnZone");
                foreach (XElement node in nodes)
                {
                    string name = node.Attribute("enemy").Value;
                    Rectangle rect = node.Attribute("zone").Value.toRectangle();
                    int count = node.Attribute("count").Value.toInt();

                    EnemyManager.Instance.addEnemySpawnZone(new EnemySpawnZone(name, rect, count));
                }

                // read level collisions
                nodes = xml_doc.Descendants("levelCollision");
                foreach (XElement node in nodes)
                {
                    Line l = new Line(node.Attribute("p1").Value.toVector2(), node.Attribute("p2").Value.toVector2());
                    LevelManager.Instance.addLevelCollision(l);
                }

                //Camera
                nodes = xml_doc.Descendants("cameraNode");
                foreach (XElement node in nodes)
                {
                    Vector3 position = node.Attribute("position").Value.toVector3();
                    Vector3 target = node.Attribute("target").Value.toVector3();
                    int nodeId = node.Attribute("id").Value.toInt();
                    bool isFirst = node.Attribute("isFirst").Value.toBool();
                    NetworkNode<CameraData> cameraNode = new NetworkNode<CameraData>(new CameraData(target, nodeId, isFirst), position);
                    if (node.Attributes("speed").Count() > 0)
                        cameraNode.value.speed = node.Attribute("speed").Value.toFloat();

                    if (node.Attributes("link").Count() > 0)
                        cameraNode.value.next = node.Attribute("link").Value.toInt();

                    CameraManager.Instance.addNode(cameraNode);
                }
                //link camera nodes
                foreach (NetworkNode<CameraData> cameraNode in CameraManager.Instance.getNodes().getNodes())
                {
                    cameraNode.addLinkedNode(CameraManager.Instance.getNode(cameraNode.value.next));
                }
                CameraManager.Instance.setupCamera();

                // player
                if (GamerManager.getMainPlayer() == null)
                {
                    GamerManager.createGamerEntity(PlayerIndex.One, true);
                }

                nodes = xml_doc.Descendants("player");
                foreach (XElement node in nodes)
                {
                    int playerId = node.Attribute("playerId").Value.toInt();
                    Vector3 pos = node.Attribute("pos").Value.toVector3();
                    GamerManager.getMainPlayer().initPos = pos;
                }

                if (fileName == "Content/xml/levels/mapa.xml")
                {
                    GamerManager.getMainPlayer().renderState = RenderableEntity2D.tRenderState.NoRender;
                }
                else
                {
                    EntityManager.Instance.registerEntity(GamerManager.getMainPlayer());
                    GamerManager.getMainPlayer().renderState = RenderableEntity2D.tRenderState.Render;
                    GamerManager.getMainPlayer().position = GamerManager.getMainPlayer().initPos;
                }
                GamerManager.getMainPlayer().initLevel();

                //particles
                nodes = xml_doc.Descendants("particle");
                foreach (XElement node in nodes)
                {
                    string name = node.Attribute("name").Value;
                    Vector3 position = node.Attribute("position").Value.toVector3();
                    Vector3 direction = node.Attribute("direction").Value.toVector3();
                    Color color = node.Attribute("color").Value.toColor();
                    if(!position.AnyNanCoord() && !direction.AnyNanCoord())
                        ParticleManager.Instance.addParticles(name, position, direction, color);
                }

                //triggers
                //nodes = xml_doc.Descendants("trigger");
                //foreach (XElement node in nodes)
                //{
                //    Vector2 position = node.Attribute("position").Value.toVector2();
                //    Trigger trigger = new Trigger();
                //    trigger.position = position;

                //    IEnumerable<XElement> moreNodes = node.Descendants("condition");
                //    foreach (XElement func in moreNodes)
                //    {
                //        trigger.addFunction(true, func.Attribute("functionName").Value);
                //    }

                //    moreNodes = node.Descendants("consecuence");
                //    foreach (XElement func in moreNodes)
                //    {
                //        trigger.addFunction(false, func.Attribute("functionName").Value);
                //    }

                //    TriggerManager.Instance.addTrigger(trigger);
                //}

                if (loadIDs)
                {
                    // groups
                    nodes = xml_doc.Descendants("group"); // read enemies
                    foreach (XElement node in nodes)
                    {
                        IEnumerable<XElement> ids = node.Descendants("entity");
                        List<int> idList = new List<int>();
                        foreach (XElement entityId in ids)
                        {
                            int entityID = entityId.Attribute("id").Value.toInt();
                            if (EntityManager.Instance.getEntityByID(entityID) != null)
                            {
                                idList.Add(entityID);
                            }
                        }
                        if(idList.Count > 1)
                            LevelManager.Instance.addGroup(idList);
                    }
                }
            }

            return list;
        }