Exemplo n.º 1
0
        public override object Update()
        {
            health--;
            if (health == 0)
            {
                return(true);
            }
            if (vel[0] != 0)
            {
                //Entity.Game.DebugBreakPoint();

                float[] raw = { ((chunkX * 8) + X), ((chunkY * 8) + Y) };
                float[] dir = new float[2];
                dir[1] = 0;
                if (vel[0] > 0)
                {
                    vel[1] /= (1.25F);
                    dir[0]  = Math.Max(-0.01F + vel[0], 0);
                    vel[0]  = dir[0];
                }
                else if (vel[0] < 0)
                {
                    vel[1] /= (1.25F);
                    dir[0]  = Math.Min(0.01F + vel[0], 0);
                    vel[0]  = dir[0];
                }

                if (LCM.IsBlocking(raw))
                {
                    Entity.Game.DebugBreakPoint();

                    vel[0] = 0;
                }
                else
                {
                    LCM.MoveDir(this, dir);
                }
            }
            if (vel[1] != 0)
            {
                //Entity.Game.DebugBreakPoint();

                float[] raw = { ((chunkX * 8) + X), ((chunkY * 8) + Y) };
                float[] dir = new float[2];
                dir[0] = 0;
                if (vel[1] > 0)
                {
                    vel[1] /= (1.25F);
                    dir[1]  = Math.Max(-0.1F + vel[1], 0);
                    vel[1]  = dir[1];
                }
                else if (vel[1] < 0)
                {
                    vel[1] /= (1.25F);
                    dir[1]  = Math.Min(0.1F + vel[1], 0);
                    vel[1]  = dir[1];
                }

                if (LCM.IsBlocking(raw))
                {
                    Entity.Game.DebugBreakPoint();

                    vel[1] = 0;
                }
                else
                {
                    LCM.MoveDir(this, dir);
                }
            }
            if (bounce > 0)
            {
                Z += vel[2];
                if (Z < 0)
                {
                    Z = 0;
                    bounce--;
                    vel[2] = (bounce * 0.1F) + 0.03F;
                }
                if (vel[2] > -0.5F)
                {
                    vel[2] -= 0.08F;
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        public void Update(Action a)
        {
            if (a == Action.move_down || a == Action.move_up || a == Action.move_left || a == Action.move_right)
            {
                moveClock = (byte)((moveClock + 1) % 64);
                if (a == Action.move_down)
                {
                    facing = EdgedAdventure.Directions.down;
                    float[] raw = new float[2];
                    raw[0] = (chunkX * 8) + X;
                    raw[1] = (chunkY * 8) + Y + movementSpeed;
                    if (!LCM.IsBlocking(raw))
                    {
                        if (Y + movementSpeed >= 8)
                        {
                            { }

                            chunkY++;
                            Y = ((Y - (8 - movementSpeed)) % 8);
                        }
                        else
                        {
                            Y += movementSpeed;
                        }
                    }
                }
                else if (a == Action.move_up)
                {
                    facing = EdgedAdventure.Directions.up;
                    float[] raw = new float[2];
                    raw[0] = (chunkX * 8) + X;
                    raw[1] = (chunkY * 8) + Y - movementSpeed;


                    if (!LCM.IsBlocking(raw))
                    {
                        if (Y - movementSpeed < 0)
                        {
                            { }

                            chunkY--;
                            Y = ((Y + (8 - movementSpeed)) % 8);
                        }
                        else
                        {
                            Y -= movementSpeed;
                        }
                    }
                }
                else if (a == Action.move_left)
                {
                    facing = EdgedAdventure.Directions.left;
                    float[] raw = new float[2];
                    raw[0] = (chunkX * 8) + X - movementSpeed;
                    raw[1] = (chunkY * 8) + Y;
                    if (!LCM.IsBlocking(raw))
                    {
                        if (X - movementSpeed < 0)
                        {
                            { }

                            chunkX--;
                            X = ((X + (8 - movementSpeed)) % 8);
                        }
                        else
                        {
                            X -= movementSpeed;
                        }
                    }
                }
                else if (a == Action.move_right)
                {
                    facing = EdgedAdventure.Directions.right;
                    float[] raw = new float[2];
                    raw[0] = (chunkX * 8) + X + movementSpeed;
                    raw[1] = (chunkY * 8) + Y;
                    if (!LCM.IsBlocking(raw))
                    {
                        if (X + movementSpeed >= 8)
                        {
                            { }

                            chunkX++;
                            X = ((X - (8 - movementSpeed)) % 8);
                        }
                        else
                        {
                            X += movementSpeed;
                        }
                    }
                }
            }
            else if (a == Action.attack)
            {
                if (energy > 0 && sel == -1)
                {
                    energy -= 40;
                    if ((0 <= moveClock && moveClock < 16) || (32 <= moveClock && moveClock < 48))
                    {
                        moveClock += 16;
                        moveClock %= 64;
                    }
                    else
                    {
                        moveClock += 32;
                        moveClock %= 64;
                    }

                    Game.DebugBreakPoint();

                    Effect slash = (Effect)Entity.GetEntity(1);
                    slash.chunkX = this.chunkX;
                    slash.chunkY = this.chunkY;
                    slash.layer  = this.layer;
                    int[] dir = DirVector(facing);
                    slash.X      = this.X + (dir[0] * 0.8F);
                    slash.Y      = this.Y + (dir[1] * 0.8F);
                    slash.health = 1;
                    slash.tile   = @"particles\slash_" + DirString(facing);
                    int[] index = LCM.GetIndices(new float[] { ((slash.chunkX * 8) + slash.X), ((slash.chunkY * 8) + slash.Y) });
                    LCM.world[index[0], index[1]].ents.Add(slash);

                    float[] raw      = { ((chunkX * 8) + slash.X), ((chunkY * 8) + slash.Y) };
                    Entity  attacked = LCM.GetAttackableEntityInRadius(raw, 0.8F);
                    if (attacked != null)
                    {
                        uint attackDamage = 1;
                        if (selItem != -1)
                        {
                            attackDamage += inv[selItem].attackBonus;
                        }
                        if (attacked.Attack(attackDamage))
                        {
                            LCM.RemoveEntity(attacked);
                        }
                    }
                    else
                    {
                        Item use = null;
                        if (selItem != -1)
                        {
                            use = inv[selItem];
                        }
                        LCM.MineAt(raw, use);
                    }
                }
            }
            else if (a == Action.test)
            {
                //Game.DebugBreakPoint();

                energy = 500;
            }

            X %= 8;
            Y %= 8;
        }