Пример #1
0
        private Fixture createVision(Orientation orientation)
        {
            Vertices vertices = new Vertices();

            if (orientation == Orientation.Right)
            {
                vertices.Add(new Vector2(0f, 0.75f));
                vertices.Add(new Vector2(0f, -0.75f));
                vertices.Add(new Vector2(5f, 0.75f));
                vertices.Add(new Vector2(5f, -0.75f));
            }
            else
            {
                vertices.Add(new Vector2(0f, 0.75f));
                vertices.Add(new Vector2(0f, -0.75f));
                vertices.Add(new Vector2(-5f, 0.75f));
                vertices.Add(new Vector2(-5f, -0.75f));
            }

            Shape   shape         = new PolygonShape(vertices, 0f);
            Fixture detectionCone = ObjectBody.CreateFixture(shape);

            detectionCone.Tag           = "DetectionCone";
            detectionCone.IsSensor      = true;
            detectionCone.OnCollision  += PlayerSpoted;
            detectionCone.OnSeparation += PlayerOutOfSight;
            return(detectionCone);
        }
Пример #2
0
 public void wellOn()
 {
     if (!roomMeta_now.WellON)
     {
         ObjectBody.GetComponent <well>().BloodProcess();
         roomMeta_now.WellON    = true;
         gameManager.wellpoint += 1;
     }
 }
Пример #3
0
 public FinishDoor(ScreenManager screenManager, World world, Vector2 pos, string propName, Vector2 objectBodySize, Vector2 objectTextureMetersSize, int columns, int rows, Level sourceLevel) : base(screenManager, propName, objectBodySize, objectTextureMetersSize, columns, rows, sourceLevel)
 {
     ObjectBody = world.CreateBody(pos);
     ObjectBody.CreateRectangle(_objectBodySize.X, _objectBodySize.Y, 0f, Vector2.Zero);
     ObjectBody.SetIsSensor(true);
     ObjectBody.OnCollision  += SomethingNearDoor;
     ObjectBody.OnSeparation += SomethingAwayFromDoor;
     PlayerNearDoor           = false;
 }
Пример #4
0
    public void already_open()
    {
        is_collide        = false;
        doorType          = unlocked_doorType;
        unlocked_doorType = DoorType.NONE;

        Vector3 position = new Vector3(ObjectBody.transform.position.x, ObjectBody.transform.position.y);

        ObjectBody.SetActive(false);
        ObjectBody = gameManager.pools.objectBodyPool.get_body(doorType, position, UDLR);
    }
Пример #5
0
        public void HandleInput(InputHelper inputHelper, GameTime gameTime)
        {
            CreatureState prevState = CreatureState;

            _playerMovingForce = new Vector2(0, 0);
            CreatureState      = CreatureState.Idle;
            if (inputHelper.KeyboardState.IsKeyDown(KeyBinds.PlayerMoveLeft))
            {
                _playerMovingForce += new Vector2(x: -_baseVelocity, 0);
                _creatureEffect     = SpriteEffects.None | SpriteEffects.FlipVertically;
                CreatureState       = CreatureState.Moving;
            }

            if (inputHelper.KeyboardState.IsKeyDown(KeyBinds.PlayerMoveRight))
            {
                _playerMovingForce += new Vector2(x: _baseVelocity, 0);
                _creatureEffect     = SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically;
                CreatureState       = CreatureState.Moving;
            }

            if (inputHelper.IsNewKeyPress(KeyBinds.PlayerJump) && !_inAir)
            {
                ObjectBody.ApplyLinearImpulse(new Vector2(0f, 1f));
                CreatureState = CreatureState.Jump;
                if (GameSettings._Volume)
                {
                    SoundEffects.PlayerjumpSoundEffects.Play();
                }
            }

            if (inputHelper.IsNewKeyPress(KeyBinds.PlayerInteract))
            {
                if (_nearInteractable != null)
                {
                    _nearInteractable.Interact(gameTime);
                }
            }

            if (_inAir)
            {
                CreatureState = CreatureState.Jump;
            }

            if (prevState == CreatureState.Attack)
            {
                CreatureState = CreatureState.Attack;
            }
        }
Пример #6
0
    public override bool interaction(ObjectBase objectBase)
    {
        if (objectBase is PlayerBase)
        {
            if (gameManager.wellpoint == Constant.WELL_POINT)
            {
                //gameManager.stage_start(1);
                ObjectBody.GetComponent <MagicCircle>().stage_up();
            }
            else
            {
                Debug.Log("need more well point");
            }
        }

        return(false);
    }
    public override Node next_node()
    {
        //Node next_node = Tools.BFS.get_next_node(this, gameManager.playerBase);
        if (!attackReady)
        {
            ObjectBody.GetComponent <Trap_normal_attackready>().activeattack();
            attackReady = true;
        }
        else
        {
            ObjectBody.GetComponent <Trap_normal_attackready>().unactiveattack();
            attackReady = false;
        }
        Node next_node = node_now;

        return(next_node);
    }
Пример #8
0
        public Ground(ScreenManager screenManager, string propName, Vector2 pos, World world, int columns, int rows, List <List <char> > level, Int32 i, Int32 j, Level sourceLevel) : base(screenManager, propName, new Vector2(1f, 1f), new Vector2(1f, 1f), columns, rows, sourceLevel)
        {
            ObjectBody          = world.CreateRectangle(_objectBodySize.X, _objectBodySize.Y, 1f, pos);
            ObjectBody.BodyType = BodyType.Static;
            ObjectBody.SetRestitution(0f);
            ObjectBody.SetFriction(0.5f);
            if (j == 0)
            {
                _currColumn = 0;
            }
            else if (level[i][j - 1] == '.')
            {
                if (j != level[i].Count - 1)
                {
                    if (level[i][j + 1] == '.')
                    {
                        _currColumn = 1;
                    }
                }
                else
                {
                    _currColumn = 0;
                }
            }
            else if (j == level[i].Count - 1)
            {
                _currColumn = 2;
            }
            else if (level[i][j + 1] == '.')
            {
                _currColumn = 2;
            }
            else
            {
                _currColumn = 1;
            }

            if (rows > 1)
            {
                _currColumn = j;
                _currRow    = i;
            }
        }
Пример #9
0
        public Player(ScreenManager screenManager, string propName, Vector2 pos, World world, int columns, int rows, Level sourceLevel) : base(screenManager, propName, new Vector2(0.75f, 0.25f), new Vector2(0.75f, 0.75f), columns, rows, sourceLevel)
        {
            _x            = 0;
            _y            = 0;
            _baseVelocity = 0.05f;
            Health        = 100;

            ObjectBody          = world.CreateCapsule(_objectBodySize.X, 0.25f, 10, _objectBodySize.Y, 10, 1f, pos);
            ObjectBody.BodyType = BodyType.Dynamic;
            ObjectBody.SetRestitution(0f);
            ObjectBody.Mass          = 2f;
            ObjectBody.FixedRotation = true;
            ObjectBody.SetFriction(1.0f);
            ObjectBody.OnSeparation += Seperation;
            ObjectBody.Tag           = "Player";

            AnimationTimeSpans = new Dictionary <CreatureState, TimeSpan>();
            AnimationTimeSpans[CreatureState.Moving] = TimeSpan.FromMilliseconds(200);
            foreach (var fixture1 in ObjectBody.FixtureList)
            {
                fixture1.Tag = "Player";
            }

            ObjectBody.SetCollisionCategories((Category)(Category.All - Category.Cat1));

            //create bottom rectangle for floor detection
            Vertices vertices = PolygonTools.CreateRectangle(0.1f, 0.1f);

            vertices.Translate(new Vector2(0f, -0.4f));
            Shape   rectangle = new PolygonShape(vertices, 1f);
            Fixture fixture   = ObjectBody.CreateFixture(rectangle);

            fixture.Tag          = "AirDetectorBottom";
            fixture.IsSensor     = true;
            fixture.OnSeparation = fixtureSeperated;
            fixture.OnCollision += Colided;
            //set sound effect

//            PlayerBody.CreateRectangle(0.2f, 0.2f, 1f, new Vector2(0f, -0.8f)).IsSensor = true;
            _inAir             = true;
            _isMoving          = false;
            _playerMovingForce = new Vector2(0, 0);
        }
Пример #10
0
    public override bool death()
    {
        ObjectBase tempbase;

        tempbase = gameManager.sub_managers.boardManager.create_object(ObjectBaseType.ITEM, (int)result_item, node_now);
        gameManager.sub_managers.animManager.anim_add(tempbase, AnimType.LANDING, 0, _priority: 0);

        if (ObjectBody.GetComponent <ObjectBody>())
        {
            ObjectBody.GetComponent <ObjectBody>().DeathTrigger          = true;
            ObjectBody.GetComponent <ObjectBody>().RoomNowForDeathEffect = gameManager.roomMeta_now;
        }
        else
        {
            Debug.Log("there is no objectbody script");
        }
        for (int i = 0; i < ItemUIList.Count; i++)
        {
            gameManager.sub_managers.animManager.animCoroutinePool.run_coroutine_withoutbase(ItemUIList[i], AnimType.DEATH, 0);
        }
        for (int i = 0; i < heartUIList.Count; i++)
        {
            if (heartUIList[i])
            {
                gameManager.sub_managers.animManager.animCoroutinePool.run_coroutine_withoutbase(heartUIList[i], AnimType.DEATH, 0);
            }
        }
        for (int i = 0; i < blueheartUIList.Count; i++)
        {
            if (blueheartUIList[i])
            {
                gameManager.sub_managers.animManager.animCoroutinePool.run_coroutine_withoutbase(blueheartUIList[i], AnimType.DEATH, 0);
            }
        }

        gameManager.roomMeta_now.room_stain_list.Add(ObjectBody);
        gameManager.sub_managers.animManager.anim_add(this, AnimType.DEATHWITHOUTDELAY, 0, 1);
        node_now.object_here_list.Remove(this);
        is_alive = false;

        return(true);
    }
Пример #11
0
        public Enemy(ScreenManager screenManager, Player player, string propName, Vector2 pos, World world, Vector2 objectBodySize, Vector2 objectTextureMetersSize, int columns, int rows, Level sourceLevel) : base(screenManager, propName, objectBodySize, objectTextureMetersSize, columns, rows, sourceLevel)
        {
            ObjectBody          = world.CreateCapsule(_objectBodySize.X, _objectBodySize.Y / 3f, 10, _objectBodySize.Y / 3f, 10, 1f, pos);
            ObjectBody.BodyType = BodyType.Dynamic;
            ObjectBody.SetRestitution(0f);
            ObjectBody.Mass          = 2f;
            ObjectBody.FixedRotation = true;
            ObjectBody.SetFriction(0.5f);
            ObjectBody.Tag = "Enemy";


            Health                = 100;
            _playerSeen           = false;
            _gotHit               = false;
            _canShoot             = true;
            _player               = player;
            _timeSinceLastMissile = TimeSpan.Zero;
            _orientation          = (Orientation)RandomNumberGenerator.GetInt32(2);
            if (_orientation == Orientation.Left)
            {
                _creatureEffect = SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically;
            }
            _leftCone  = createVision(Orientation.Left);
            _rightCone = createVision(Orientation.Right);
            foreach (var fixture in ObjectBody.FixtureList)
            {
                if (!"DetectionCone".Equals(fixture.Tag))
                {
                    fixture.Tag = "Enemy";
                }
            }

            _healthBarColor = Color.Green;
            makeHealthBar();

            ObjectBody.OnCollision += OnCollision;
        }
Пример #12
0
        public MagicMissile(ScreenManager screenManager, World world, Vector2 pos, Vector2 cursorPos, ICanSpawnMissiles parentObject, int columns, int rows, Level sourceLevel) : base(screenManager, "Textures/magicMissile",
                                                                                                                                                                                       new Vector2(0.05f), new Vector2(0.25f), columns, rows, sourceLevel)
        {
            _world          = world;
            _parentObject   = parentObject;
            directionVector = cursorPos - pos;
            _originalPos    = pos;
            directionVector.Normalize();
            CircleShape shape = new CircleShape(0.05f, 20f);

            ObjectBody          = world.CreateBody();
            ObjectBody.BodyType = BodyType.Dynamic;
            ObjectBody.IsBullet = true;
            ObjectBody.Position = pos + (directionVector / 2);
            ObjectBody.SetCollisionCategories(Category.Cat1);
            ObjectBody.IgnoreGravity = true;
            ObjectBody.Mass          = 0.01f;


            Fixture fixture = ObjectBody.CreateFixture(shape);

            fixture.Restitution = 0.05f;
            if (GameSettings._Volume)
            {
                SoundEffects.MissileOut.Play();
            }

            ObjectBody.LinearVelocity = directionVector * 10f;
            ObjectBody.OnCollision   += Collided;

            ObjectBody.Tag = "MagicMissile";
            foreach (var fixture1 in ObjectBody.FixtureList)
            {
                fixture1.Tag = "MagicMissile";
            }
        }
Пример #13
0
 public override int[] attack(ObjectBase targetBase)
 {
     ObjectBody.GetComponentInChildren <zombie>().setAttackSound();
     direction_onleLR(targetBase.node_now);
     return(base.attack(targetBase));
 }
Пример #14
0
    public override bool death()
    {
        ObjectBase tempbase;
        int        rand_item_idx = Random.Range(0, 20);

        if (rand_item_idx == 0)
        {
            tempbase = gameManager.sub_managers.boardManager.create_object(ObjectBaseType.ITEM, (int)ItemType.ITEM_KEY, node_now);
            gameManager.sub_managers.animManager.anim_add(tempbase, AnimType.LANDING, 0, _priority: 0);
        }
        else if (rand_item_idx == 1)
        {
            tempbase = gameManager.sub_managers.boardManager.create_object(ObjectBaseType.ITEM, (int)ItemType.ITEM_HEART, node_now);
            gameManager.sub_managers.animManager.anim_add(tempbase, AnimType.LANDING, 0, _priority: 0);
        }
        else if (rand_item_idx == 2)
        {
            tempbase = gameManager.sub_managers.boardManager.create_object(ObjectBaseType.ITEM, (int)ItemType.ITEM_SWORD, node_now);
            gameManager.sub_managers.animManager.anim_add(tempbase, AnimType.LANDING, 0, _priority: 0);
        }
        else if (rand_item_idx == 3)
        {
            tempbase = gameManager.sub_managers.boardManager.create_object(ObjectBaseType.ITEM, (int)ItemType.ITEM_SHIELD, node_now);
            gameManager.sub_managers.animManager.anim_add(tempbase, AnimType.LANDING, 0, _priority: 0);
        }
        else if (rand_item_idx == 4)
        {
            tempbase = gameManager.sub_managers.boardManager.create_object(ObjectBaseType.ITEM, (int)ItemType.ITEM_BAG, node_now);
            gameManager.sub_managers.animManager.anim_add(tempbase, AnimType.LANDING, 0, _priority: 0);
        }
        else if (rand_item_idx == 5)
        {
            tempbase = gameManager.sub_managers.boardManager.create_object(ObjectBaseType.ITEM, (int)ItemType.ITEM_BAG_HERAT, node_now);
            gameManager.sub_managers.animManager.anim_add(tempbase, AnimType.LANDING, 0, _priority: 0);
        }
        else if (rand_item_idx == 6)
        {
            tempbase = gameManager.sub_managers.boardManager.create_object(ObjectBaseType.ITEM, (int)ItemType.ITEM_BLUEHEART, node_now);
            gameManager.sub_managers.animManager.anim_add(tempbase, AnimType.LANDING, 0, _priority: 0);
        }


        if (ObjectBody.GetComponent <ObjectBody>())
        {
            ObjectBody.GetComponent <ObjectBody>().DeathTrigger          = true;
            ObjectBody.GetComponent <ObjectBody>().RoomNowForDeathEffect = gameManager.roomMeta_now;
        }
        else
        {
            Debug.Log("there is no objectbody script");
        }
        for (int i = 0; i < ItemUIList.Count; i++)
        {
            gameManager.sub_managers.animManager.animCoroutinePool.run_coroutine_withoutbase(ItemUIList[i], AnimType.DEATH, 0);
        }
        for (int i = 0; i < heartUIList.Count; i++)
        {
            if (heartUIList[i])
            {
                gameManager.sub_managers.animManager.animCoroutinePool.run_coroutine_withoutbase(heartUIList[i], AnimType.DEATH, 0);
            }
        }
        for (int i = 0; i < blueheartUIList.Count; i++)
        {
            if (blueheartUIList[i])
            {
                gameManager.sub_managers.animManager.animCoroutinePool.run_coroutine_withoutbase(blueheartUIList[i], AnimType.DEATH, 0);
            }
        }

        gameManager.roomMeta_now.room_stain_list.Add(ObjectBody);
        gameManager.sub_managers.animManager.anim_add(this, AnimType.DEATHWITHOUTDELAY, 0, 1);
        node_now.object_here_list.Remove(this);
        is_alive = false;

        return(true);
    }
 void open()
 {
     ObjectBody.GetComponent <well>().unlock();
     isLocked = false;
 }