예제 #1
0
파일: World.cs 프로젝트: maggardJosh/OGREAT
    private void EnemyTransition(FutileFourDirectionBaseObject.Direction dir, FutilePlatformerBaseObject enemy)
    {
        if (enemy is Enemy)
        {
            Enemy e = ((Enemy)enemy);
            e.SetDirection(dir);
            e.PlayAnim();
        }
        else if (enemy is Ninja)
        {

            Ninja n = ((Ninja)enemy);
            n.SetDirection(dir);
            n.PlayAnim();
        }

        Tween t = null;
        float randAmount = 8.0f;
        float minAmount = 1.0f;
        switch (dir)
        {
            case FutileFourDirectionBaseObject.Direction.DOWN:
                enemy.y += collisionTilemap.tileHeight * 2f;
                enemy.x += RXRandom.Float() * 2 * collisionTilemap.tileWidth - collisionTilemap.tileWidth;
                t = Go.to(enemy, minAmount, new TweenConfig().setEaseType(EaseType.QuadOut).setDelay(RXRandom.Float() * randAmount).floatProp("y", -collisionTilemap.tileHeight * 2f, true));
                break;
            case FutileFourDirectionBaseObject.Direction.UP:
                enemy.y -= collisionTilemap.tileHeight * 2f;
                enemy.x += RXRandom.Float() * 2 * collisionTilemap.tileWidth - collisionTilemap.tileWidth;
                t = Go.to(enemy, minAmount, new TweenConfig().setEaseType(EaseType.QuadOut).setDelay(RXRandom.Float() * randAmount).floatProp("y", collisionTilemap.tileHeight * 2f, true));
                break;
            case FutileFourDirectionBaseObject.Direction.RIGHT:
                enemy.x -= collisionTilemap.tileWidth * 2f;
                enemy.y += RXRandom.Float() * 2 * collisionTilemap.tileHeight - collisionTilemap.tileHeight;
                t = Go.to(enemy, minAmount, new TweenConfig().setEaseType(EaseType.QuadOut).setDelay(RXRandom.Float() * randAmount).floatProp("x", collisionTilemap.tileWidth * 2f, true));
                break;
            case FutileFourDirectionBaseObject.Direction.LEFT:
                enemy.x += collisionTilemap.tileWidth * 2f;
                enemy.y += RXRandom.Float() * 2 * collisionTilemap.tileHeight - collisionTilemap.tileHeight;
                t = Go.to(enemy, minAmount, new TweenConfig().setEaseType(EaseType.QuadOut).setDelay(RXRandom.Float() * randAmount).floatProp("x", -collisionTilemap.tileWidth * 2f, true));
                break;
        }
        t.setOnCompleteHandler((AbstractTween tw) =>
        {
            if (enemy is Enemy)
            {
                Enemy e = ((Enemy)enemy);
                e.currentState = Enemy.State.IDLE;
                e.StateCount = 1;

            }
            else if (enemy is Ninja)
            {
                Ninja n = ((Ninja)enemy);
                n.currentState = Ninja.State.IDLE;
                n.StateCount = 1;
            }
        });
    }
예제 #2
0
파일: World.cs 프로젝트: maggardJosh/OGREAT
 private void SpawnEnemy(FutilePlatformerBaseObject enemy)
 {
     enemySpawns[RXRandom.Int(enemySpawns.Count())].SpawnEnemy(enemy);
     AddObject(enemy);
     if (enemy.y > -collisionTilemap.tileHeight)    //Top
         EnemyTransition(FutileFourDirectionBaseObject.Direction.DOWN, enemy);
     else if (enemy.y < -collisionTilemap.height + collisionTilemap.tileHeight)   //bottom
         EnemyTransition(FutileFourDirectionBaseObject.Direction.UP, enemy);
     else if (enemy.x < collisionTilemap.tileWidth)   //left
         EnemyTransition(FutileFourDirectionBaseObject.Direction.RIGHT, enemy);
     else
         EnemyTransition(FutileFourDirectionBaseObject.Direction.LEFT, enemy);
 }
예제 #3
0
파일: World.cs 프로젝트: maggardJosh/OGREAT
 public bool isAllPassable(FutilePlatformerBaseObject self, float x, float y, bool isMovingHorizontal = true)
 {
     float xPos = x + self.hitBox.x + (isMovingHorizontal ? 0 : -1);
     float yPos = y + self.hitBox.y + (isMovingHorizontal ? -1 : 0);
     float width = self.hitBox.width + (isMovingHorizontal ? 0 : -4);
     float height = self.hitBox.height + (isMovingHorizontal ? -4 : 0);
     return
         isWallPassable(xPos - width / 2f, yPos - height / 2f) &&
         isWallPassable(xPos + width / 2f, yPos - height / 2f) &&
         isWallPassable(xPos - width / 2f, yPos + height / 2f) &&
         isWallPassable(xPos + width / 2f, yPos + height / 2f) &&
         isPassable(xPos - width / 2f, yPos - height / 2f) &&
         isPassable(xPos + width / 2f, yPos - height / 2f) &&
         isPassable(xPos - width / 2f, yPos + height / 2f) &&
         isPassable(xPos + width / 2f, yPos + height / 2f);
 }
예제 #4
0
파일: World.cs 프로젝트: maggardJosh/OGREAT
 public void RemoveObject(FutilePlatformerBaseObject o)
 {
     objects.Remove(o);
     playerLayer.RemoveChild(o);
 }
예제 #5
0
파일: World.cs 프로젝트: maggardJosh/OGREAT
 public void AddObject(FutilePlatformerBaseObject o)
 {
     objects.Add(o);
     playerLayer.AddChild(o);
 }
예제 #6
0
파일: World.cs 프로젝트: maggardJosh/OGREAT
 public RXRect CheckObjectCollision(FutilePlatformerBaseObject self, float x, float y)
 {
     foreach (FutilePlatformerBaseObject o in objects)
     {
         if (!self.collidesWithOtherObjects)
             continue;
         if (!o.blocksOtherObjects)
             continue;
         if (o == self)
             continue;
         if ((self is Player && o is Enemy) ||
             (self is Enemy && o is Player) ||
             (self is Player && o is Ninja) ||
             (self is Ninja && o is Player))
             continue;
         worldPos.x = o.x + o.hitBox.x - o.hitBox.width / 2;
         worldPos.y = o.y + o.hitBox.y - o.hitBox.height / 2;
         worldPos.width = o.hitBox.width;
         worldPos.height = o.hitBox.height;
         if (worldPos.Contains(x, y))
         {
             return worldPos;
         }
     }
     return null;
 }
예제 #7
0
    public Player(World world)
        : base(new RXRect(0, -8, 8, 6), world)
    {
        swordCollision = new FutilePlatformerBaseObject(new RXRect(6, -8, 15, 10), world);

        maxXVel = 1;
        maxYVel = 1;
        minYVel = -1;
        handleStateCount = true;
        bounceiness = 0f;
        player = new FAnimatedSprite("player");

        player.addAnimation(new FAnimation(PlayerState.IDLE.ToString() + Direction.RIGHT.ToString(), new int[] { 9 }, 100, true));
        player.addAnimation(new FAnimation(PlayerState.IDLE.ToString() + Direction.LEFT.ToString(), new int[] { 9 }, 100, true));
        player.addAnimation(new FAnimation(PlayerState.IDLE.ToString() + Direction.UP.ToString(), new int[] { 5 }, 100, true));
        player.addAnimation(new FAnimation(PlayerState.IDLE.ToString() + Direction.DOWN.ToString(), new int[] { 1 }, 100, true));

        player.addAnimation(new FAnimation(PlayerState.INVULNERABLE.ToString() + Direction.RIGHT.ToString(), new int[] { 9 }, 100, true));
        player.addAnimation(new FAnimation(PlayerState.INVULNERABLE.ToString() + Direction.LEFT.ToString(), new int[] { 9 }, 100, true));
        player.addAnimation(new FAnimation(PlayerState.INVULNERABLE.ToString() + Direction.UP.ToString(), new int[] { 5 }, 100, true));
        player.addAnimation(new FAnimation(PlayerState.INVULNERABLE.ToString() + Direction.DOWN.ToString(), new int[] { 1 }, 100, true));

        player.addAnimation(new FAnimation(PlayerState.DYING.ToString() + Direction.RIGHT.ToString(), new int[] { 9 }, 100, true));
        player.addAnimation(new FAnimation(PlayerState.DYING.ToString() + Direction.LEFT.ToString(), new int[] { 9 }, 100, true));
        player.addAnimation(new FAnimation(PlayerState.DYING.ToString() + Direction.UP.ToString(), new int[] { 5 }, 100, true));
        player.addAnimation(new FAnimation(PlayerState.DYING.ToString() + Direction.DOWN.ToString(), new int[] { 1 }, 100, true));

        player.addAnimation(new FAnimation(PlayerState.MOVE.ToString() + Direction.RIGHT.ToString(), new int[] { 9, 10, 9, 12 }, 150, true));
        player.addAnimation(new FAnimation(PlayerState.MOVE.ToString() + Direction.LEFT.ToString(), new int[] { 9, 10, 9, 12 }, 150, true));
        player.addAnimation(new FAnimation(PlayerState.MOVE.ToString() + Direction.UP.ToString(), new int[] { 5, 6, 5, 8 }, 150, true));
        player.addAnimation(new FAnimation(PlayerState.MOVE.ToString() + Direction.DOWN.ToString(), new int[] { 1, 2, 1, 4 }, 150, true));

        player.addAnimation(new FAnimation(PlayerState.JUMP.ToString() + Direction.RIGHT.ToString(), new int[] { 18, 19 }, 150, false));
        player.addAnimation(new FAnimation(PlayerState.JUMP.ToString() + Direction.LEFT.ToString(), new int[] { 18, 19 }, 150, false));
        player.addAnimation(new FAnimation(PlayerState.JUMP.ToString() + Direction.UP.ToString(), new int[] { 16, 17 }, 150, false));
        player.addAnimation(new FAnimation(PlayerState.JUMP.ToString() + Direction.DOWN.ToString(), new int[] { 14, 15 }, 150, false));

        int attackSpeed = 250;
        player.addAnimation(new FAnimation(PlayerState.SWORD.ToString() + Direction.RIGHT.ToString(), new int[] { 28, 29 }, attackSpeed, false));
        player.addAnimation(new FAnimation(PlayerState.SWORD.ToString() + Direction.LEFT.ToString(), new int[] { 28, 29 }, attackSpeed, false));
        player.addAnimation(new FAnimation(PlayerState.SWORD.ToString() + Direction.UP.ToString(), new int[] { 24, 25 }, attackSpeed, false));
        player.addAnimation(new FAnimation(PlayerState.SWORD.ToString() + Direction.DOWN.ToString(), new int[] { 20, 21 }, attackSpeed, false));

        player.addAnimation(new FAnimation(PlayerState.SWORD_TWO.ToString() + Direction.RIGHT.ToString(), new int[] { 30, 31 }, attackSpeed, false));
        player.addAnimation(new FAnimation(PlayerState.SWORD_TWO.ToString() + Direction.LEFT.ToString(), new int[] { 30, 31 }, attackSpeed, false));
        player.addAnimation(new FAnimation(PlayerState.SWORD_TWO.ToString() + Direction.UP.ToString(), new int[] { 26, 27 }, attackSpeed, false));
        player.addAnimation(new FAnimation(PlayerState.SWORD_TWO.ToString() + Direction.DOWN.ToString(), new int[] { 22, 23 }, attackSpeed, false));

        player.addAnimation(new FAnimation(PlayerState.BOW_DRAWN.ToString() + Direction.DOWN.ToString(), new int[] { 32, 33 }, 150, true));
        player.addAnimation(new FAnimation(PlayerState.BOW_DRAWN.ToString() + Direction.UP.ToString(), new int[] { 35, 36 }, 150, true));
        player.addAnimation(new FAnimation(PlayerState.BOW_DRAWN.ToString() + Direction.RIGHT.ToString(), new int[] { 38, 39 }, 150, true));
        player.addAnimation(new FAnimation(PlayerState.BOW_DRAWN.ToString() + Direction.LEFT.ToString(), new int[] { 38, 39 }, 150, true));

        player.addAnimation(new FAnimation(PlayerState.BOW_SHOOTING.ToString() + Direction.DOWN.ToString(), new int[] { 34 }, 150, false));
        player.addAnimation(new FAnimation(PlayerState.BOW_SHOOTING.ToString() + Direction.UP.ToString(), new int[] { 37 }, 150, false));
        player.addAnimation(new FAnimation(PlayerState.BOW_SHOOTING.ToString() + Direction.RIGHT.ToString(), new int[] { 40 }, 150, false));
        player.addAnimation(new FAnimation(PlayerState.BOW_SHOOTING.ToString() + Direction.LEFT.ToString(), new int[] { 40 }, 150, false));

        PlayAnim(true);
        this.AddChild(player);
    }
예제 #8
0
 public void CheckDamageObjectCollision(FutilePlatformerBaseObject o)
 {
     if (o is Knight)
     {
         Knight k = (Knight)o;
         k.CheckDamage(player);
     }
     else if (o is Arrow)
     {
         Arrow a = (Arrow)o;
         a.HandlePlayerCollision(player);
     }
     else if (o is Heart)
     {
         Heart h = (Heart)o;
         h.HandlePlayerCollision(player);
     }
     else if (o is MagicOrb)
     {
         MagicOrb orb = (MagicOrb)o;
         orb.HandlePlayerCollision(player);
     }
     else if (o is Ghost)
     {
         Ghost g = (Ghost)o;
         g.HandlePlayerCollision(player);
     }
     else if (o is SoulPickup)
     {
         SoulPickup s = (SoulPickup)o;
         s.HandlePlayerCollision(player);
     }
 }
예제 #9
0
    public RXRect CheckObjectCollisionHitbox(FutilePlatformerBaseObject self, float x, float y, float sideMargin = 4)
    {
        selfRect.x = x + self.hitBox.x - (self.hitBox.width - sideMargin) / 2f;
        selfRect.y = y + self.hitBox.y - (self.hitBox.height - sideMargin) / 2f;
        selfRect.width = self.hitBox.width - sideMargin;
        selfRect.height = self.hitBox.height - sideMargin;
        foreach (FutilePlatformerBaseObject o in collisionObjects)
        {
            if (!o.blocksOtherObjects && !(o is Switch))
                continue;
            if ((self is Knight && o is Player))
                continue;
            if ((self is Ghost && o is Player))
                continue;
            if (self is Arrow && ((Arrow)self).owner == o)
                continue;
            if (self is MagicOrb && ((MagicOrb)self).owner == o)
                continue;
            if (self is Arrow && o is Player)
                continue;
            if (self is MagicOrb && o is Player)
                continue;

            if (o == self)
                continue;
            worldPos.x = o.x + o.hitBox.x - o.hitBox.width / 2;
            worldPos.y = o.y + o.hitBox.y - o.hitBox.height / 2;
            worldPos.width = o.hitBox.width;
            worldPos.height = o.hitBox.height;
            if (worldPos.CheckIntersect(selfRect))
            {
                if (self is Player && o is PushBlock)
                    ((PushBlock)o).HandlePlayerCollision((Player)self);
                if (self is Player && o is Switch)
                {
                    ((Switch)o).HandlePlayerCollision((Player)self);
                    continue;
                }
                else if (o is Switch)
                    continue;
                if (self is Arrow && o is HitSwitch)
                    ((HitSwitch)o).Activate();
                return worldPos;
            }
        }
        return null;
    }
예제 #10
0
 public void SpawnEnemy(FutilePlatformerBaseObject e)
 {
     e.SetPosition(pos);
 }
예제 #11
0
    public RXRect CheckObjectCollision(FutilePlatformerBaseObject self, float x, float y)
    {
        foreach (FutilePlatformerBaseObject o in collisionObjects)
        {
            if (!o.blocksOtherObjects && !(o is Switch))
                continue;
            if ((self is Knight && o is Player))
                continue;
            if ((self is Ghost && o is Player))
                continue;
            if (self is Arrow && ((Arrow)self).owner == o)
                continue;
            if (self is MagicOrb && ((MagicOrb)self).owner == o)
                continue;
            if (self is Arrow && o is Player)
                continue;
            if (self is MagicOrb && o is Player)
                continue;

            if (o == self)
                continue;
            worldPos.x = o.x + o.hitBox.x - o.hitBox.width / 2;
            worldPos.y = o.y + o.hitBox.y - o.hitBox.height / 2;
            worldPos.width = o.hitBox.width;
            worldPos.height = o.hitBox.height;
            if (worldPos.Contains(x, y))
            {
                if (self is Player && o is PushBlock)
                    ((PushBlock)o).HandlePlayerCollision((Player)self);
                if (self is Player && o is Switch)
                {
                    ((Switch)o).HandlePlayerCollision((Player)self);
                    continue;
                }
                else if (o is Switch)
                    continue;
                if (self is Arrow && o is HitSwitch)
                    ((HitSwitch)o).Activate();
                return worldPos;
            }
        }
        return null;
    }
예제 #12
0
    public FutilePlatformerBaseObject CheckDamageObjectCollisionGetRect(FutilePlatformerBaseObject self, float x, float y)
    {
        foreach (FutilePlatformerBaseObject o in damageObjects)
        {
            if (o == self)
                continue;
            worldPos.x = o.x + o.hitBox.x - o.hitBox.width / 2;
            worldPos.y = o.y + o.hitBox.y - o.hitBox.height / 2;
            worldPos.width = o.hitBox.width;
            worldPos.height = o.hitBox.height;
            if (worldPos.Contains(x, y))
            {
                return o;
            }
        }

        return null;
    }
예제 #13
0
 public bool CheckDamageObjectCollision(FutilePlatformerBaseObject self, float x, float y)
 {
     foreach (FutilePlatformerBaseObject o in damageObjects)
     {
         if (o == self)
             continue;
         if (self is PushBlock && o is Arrow)
             continue;
         worldPos.x = o.x + o.hitBox.x - o.hitBox.width / 2;
         worldPos.y = o.y + o.hitBox.y - o.hitBox.height / 2;
         worldPos.width = o.hitBox.width;
         worldPos.height = o.hitBox.height;
         if (worldPos.Contains(x, y))
             return true;
     }
     return false;
 }
 public bool isColliding(FutilePlatformerBaseObject other)
 {
     return this.x + hitBox.x - hitBox.width / 2f < other.x + other.hitBox.x + other.hitBox.width / 2f &&
         this.x + hitBox.x + hitBox.width / 2f > other.x + other.hitBox.x - other.hitBox.width / 2f &&
         this.y + hitBox.y + hitBox.height / 2f > other.y + other.hitBox.y - other.hitBox.height / 2f &&
         this.y + hitBox.y - hitBox.height / 2f < other.y + other.hitBox.y + other.hitBox.height / 2f;
 }
예제 #15
0
 protected override bool HandleDamageObjectCollision(FutilePlatformerBaseObject damageObject)
 {
     if (damageObject is Arrow)
         return false;   //Handle this in the arrow class
     if (damageObject is Knight)
         return true;
     return base.HandleDamageObjectCollision(damageObject);
 }
 protected virtual bool HandleDamageObjectCollision(FutilePlatformerBaseObject damageObject)
 {
     return false;
 }
예제 #17
0
 public void SetTarget(FutilePlatformerBaseObject node)
 {
     target = node;
 }