Inheritance: MonoBehaviour
Ejemplo n.º 1
0
 public EnemyObj_BallAndChain(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyFlailKnight_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     this.m_ballAndChain = new ProjectileObj("EnemyFlailKnightBall_Sprite");
     this.m_ballAndChain.IsWeighted = false;
     this.m_ballAndChain.CollidesWithTerrain = false;
     this.m_ballAndChain.IgnoreBoundsCheck = true;
     this.m_ballAndChain.OutlineWidth = 2;
     this.m_ballAndChain2 = (this.m_ballAndChain.Clone() as ProjectileObj);
     this.m_chain = new SpriteObj("EnemyFlailKnightLink_Sprite");
     this.m_chainLinksList = new List<Vector2>();
     this.m_chainLinks2List = new List<Vector2>();
     for (int i = 0; i < this.m_numChainLinks; i++)
     {
         this.m_chainLinksList.Add(default(Vector2));
     }
     for (int j = 0; j < this.m_numChainLinks / 2; j++)
     {
         this.m_chainLinks2List.Add(default(Vector2));
     }
     this.Type = 1;
     this.TintablePart = this._objectList[3];
     this.m_walkSound = new FrameSoundObj(this, this.m_target, 1, new string[]
     {
         "KnightWalk1",
         "KnightWalk2"
     });
     this.m_walkSound2 = new FrameSoundObj(this, this.m_target, 6, new string[]
     {
         "KnightWalk1",
         "KnightWalk2"
     });
 }
Ejemplo n.º 2
0
 public EnemyObj_LastBoss(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("PlayerIdle_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     foreach (GameObj current in this._objectList)
     {
         current.TextureColor = new Color(100, 100, 100);
     }
     this.Type = 29;
     this.m_damageShieldProjectiles = new List<ProjectileObj>();
     this._objectList[5].Visible = false;
     this._objectList[15].Visible = false;
     this._objectList[16].Visible = false;
     this._objectList[14].Visible = false;
     this._objectList[13].Visible = false;
     this._objectList[0].Visible = false;
     string text = (this._objectList[12] as IAnimateableObj).SpriteName;
     int startIndex = text.IndexOf("_") - 1;
     text = text.Remove(startIndex, 1);
     text = text.Replace("_", 7 + "_");
     this._objectList[12].ChangeSprite(text);
     base.PlayAnimation(true);
     this.m_delayObj = new BlankObj(0, 0);
     this.m_walkDownSoundFinalBoss = new FrameSoundObj(this, 3, new string[]
     {
         "FinalBoss_St2_Foot_01",
         "FinalBoss_St2_Foot_02",
         "FinalBoss_St2_Foot_03"
     });
     this.m_walkUpSoundFinalBoss = new FrameSoundObj(this, 6, new string[]
     {
         "FinalBoss_St2_Foot_04",
         "FinalBoss_St2_Foot_05"
     });
 }
 public void Awake()
 {
     animator = GetComponent<PlayerAnimationBehavior>();
     actor = GetComponent<ActorBehaviour>();
     actor.setSpeed(speed);
     physicsmg = GetComponent<PhysicsManager>();
 }
Ejemplo n.º 4
0
 public ItemDropManager(int poolSize, PhysicsManager physicsManager)
 {
     this.m_itemDropPool = new DS2DPool<ItemDropObj>();
     this.m_itemDropsToRemoveList = new List<ItemDropObj>();
     this.m_poolSize = poolSize;
     this.m_physicsManager = physicsManager;
 }
Ejemplo n.º 5
0
 public EnemyObj_EarthWizard(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyWizardIdle_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     base.PlayAnimation(true);
     this.TintablePart = this._objectList[0];
     this.Type = 5;
 }
Ejemplo n.º 6
0
 public EnemyObj_SpikeTrap(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemySpikeTrap_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     this.Type = 21;
     base.StopAnimation();
     base.PlayAnimationOnRestart = false;
     base.NonKillable = true;
 }
Ejemplo n.º 7
0
 public EnemyObj_HomingTurret(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyHomingTurret_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     base.StopAnimation();
     base.ForceDraw = true;
     this.Type = 28;
     base.PlayAnimationOnRestart = false;
 }
Ejemplo n.º 8
0
 public EnemyObj_Spark(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemySpark_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     base.IsWeighted = false;
     base.ForceDraw = true;
     this.Type = 24;
     base.NonKillable = true;
 }
Ejemplo n.º 9
0
 public EnemyObj_Blob(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyBlobIdle_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     this.MainBlob = true;
     this.TintablePart = this._objectList[0];
     base.PlayAnimation(true);
     this.m_invincibleCounter = 0.5f;
     this.Type = 2;
 }
Ejemplo n.º 10
0
 public EnemyObj_Portrait(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyPortrait_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     this.Type = 32;
     string spriteName = "FramePicture" + CDGMath.RandomInt(1, 16) + "_Sprite";
     base.GetChildAt(0).ChangeSprite(spriteName);
     base.GetChildAt(0);
     base.DisableCollisionBoxRotations = false;
 }
Ejemplo n.º 11
0
 public EnemyObj_Zombie(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyZombieLower_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     base.GoToFrame(base.TotalFrames);
     this.Lowered = true;
     base.ForceDraw = true;
     base.StopAnimation();
     this.Type = 20;
     base.PlayAnimationOnRestart = false;
 }
Ejemplo n.º 12
0
 public EnemyObj_Mimic(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyMimicIdle_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     this.Type = 33;
     base.OutlineWidth = 0;
     this.m_closeSound = new FrameSoundObj(this, this.m_target, 1, new string[]
     {
         "Chest_Snap"
     });
 }
Ejemplo n.º 13
0
 public EnemyObj_Turret(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyTurretFire_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     base.IsCollidable = false;
     base.ForceDraw = true;
     this.Type = 17;
     base.StopAnimation();
     base.PlayAnimationOnRestart = false;
     base.NonKillable = true;
 }
Ejemplo n.º 14
0
 public ChestObj(PhysicsManager physicsManager)
     : base("Chest1_Sprite", physicsManager)
 {
     base.DisableHitboxUpdating = true;
     base.IsWeighted = false;
     base.Layer = 1f;
     base.OutlineWidth = 2;
     this.IsProcedural = true;
     this.m_arrowIcon = new SpriteObj("UpArrowSquare_Sprite");
     this.m_arrowIcon.OutlineWidth = 2;
     this.m_arrowIcon.Visible = false;
 }
Ejemplo n.º 15
0
 public EnemyObj_Wolf(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyWargIdle_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     this.Type = 19;
     this.m_startDelayCounter = this.m_startDelay;
     this.m_runFrameSound = new FrameSoundObj(this, 1, new string[]
     {
         "Wolf_Move01",
         "Wolf_Move02",
         "Wolf_Move03"
     });
 }
Ejemplo n.º 16
0
 public EnemyObj_Ninja(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyNinjaIdle_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     this.Type = 13;
     this.m_smoke = new SpriteObj("NinjaSmoke_Sprite");
     this.m_smoke.AnimationDelay = 0.05f;
     this.m_log = new SpriteObj("Log_Sprite");
     this.m_smoke.Visible = false;
     this.m_smoke.Scale = new Vector2(5f, 5f);
     this.m_log.Visible = false;
     this.m_log.OutlineWidth = 2;
 }
Ejemplo n.º 17
0
 public FairyChestObj(PhysicsManager physicsManager)
     : base(physicsManager)
 {
     this.m_lockSprite = new SpriteObj("Chest4Unlock_Sprite");
     this.m_errorSprite = new SpriteObj("CancelIcon_Sprite");
     this.m_errorSprite.Visible = false;
     this.m_timerText = new TextObj(Game.JunicodeFont);
     this.m_timerText.FontSize = 18f;
     this.m_timerText.DropShadow = new Vector2(2f, 2f);
     this.m_timerText.Align = Types.TextAlign.Centre;
     this.m_player = Game.ScreenManager.Player;
 }
Ejemplo n.º 18
0
 public EnemyObj_Eyeball(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyEyeballIdle_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     this.m_pupil = new SpriteObj("EnemyEyeballPupil_Sprite");
     this.AddChild(this.m_pupil);
     this.m_squishSound = new FrameSoundObj(this, this.m_target, 2, new string[]
     {
         "Eyeball_Prefire"
     });
     this.Type = 6;
     base.DisableCollisionBoxRotations = false;
 }
Ejemplo n.º 19
0
 public EnemyObj_Platform(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyPlatform_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     base.CollisionTypeTag = 1;
     this.Type = 27;
     base.CollidesBottom = false;
     base.CollidesLeft = false;
     base.CollidesRight = false;
     base.StopAnimation();
     base.PlayAnimationOnRestart = false;
     base.NonKillable = true;
     base.DisableCollisionBoxRotations = false;
 }
Ejemplo n.º 20
0
 public EnemyObj_ShieldKnight(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyShieldKnightIdle_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     this.Type = 14;
     this.m_walkSound = new FrameSoundObj(this, this.m_target, 1, new string[]
     {
         "KnightWalk1",
         "KnightWalk2"
     });
     this.m_walkSound2 = new FrameSoundObj(this, this.m_target, 6, new string[]
     {
         "KnightWalk1",
         "KnightWalk2"
     });
 }
Ejemplo n.º 21
0
 public World(IBus bus, Canvas canvas)
 {
     this.bus = bus;
     var centreTop = canvas.ActualHeight / 2;
     var centreLeft = canvas.ActualWidth / 2;
     var bot = new Bot(bus, new Point(centreLeft, centreTop));
     for (int i = 1; i <= 6; i++)
     {
         var angle = ((double)i / 6) * Math.PI * 2;
         var waypoint = new Waypoint(bus, new Point(centreLeft + 100 * Math.Sin(angle), centreTop + 100 * Math.Cos(angle)));
         bot.AddWaypoint(waypoint);
     }
     var manager = new TimeManager(bus);
     var physics = new PhysicsManager(bus);
 }
Ejemplo n.º 22
0
 public EnemyObj(string spriteName, PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base(spriteName, physicsManager, levelToAttachTo)
 {
     base.DisableCollisionBoxRotations = true;
     this.Type = 0;
     base.CollisionTypeTag = 3;
     this.m_target = target;
     this.m_walkingLB = new LogicBlock();
     this.m_currentActiveLB = new LogicBlock();
     this.m_cooldownLB = new LogicBlock();
     this.logicBlocksToDispose = new List<LogicBlock>();
     this.m_resetSpriteName = spriteName;
     this.Difficulty = difficulty;
     this.ProjectileScale = new Vector2(1f, 1f);
     base.PlayAnimation(true);
     this.PlayAnimationOnRestart = true;
     base.OutlineWidth = 2;
     this.GivesLichHealth = true;
     this.DropsItem = true;
 }
Ejemplo n.º 23
0
 public EnemyObj_Energon(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyEnergonIdle_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     this.Type = 23;
     this.m_shield = new SpriteObj("EnergonSwordShield_Sprite");
     this.m_shield.AnimationDelay = 0.1f;
     this.m_shield.PlayAnimation(true);
     this.m_shield.Opacity = 0.5f;
     this.m_shield.Scale = new Vector2(1.2f, 1.2f);
     this.m_projectilePool = new DS2DPool<EnergonProjectileObj>();
     for (int i = 0; i < (int)this.m_poolSize; i++)
     {
         EnergonProjectileObj energonProjectileObj = new EnergonProjectileObj("EnergonSwordProjectile_Sprite", this);
         energonProjectileObj.Visible = false;
         energonProjectileObj.CollidesWithTerrain = false;
         energonProjectileObj.PlayAnimation(true);
         energonProjectileObj.AnimationDelay = 0.05f;
         this.m_projectilePool.AddToPool(energonProjectileObj);
     }
 }
	// Use this for initialization
	void Awake()
	{
		localEventManager = new LocalEventManager();
		physicsManager = transform.Find("DownCollider").GetComponent<PhysicsManager>();
		physicsManager.character = gameObject;
		characterAttributes = GetComponent<CharacterAttributes>();
		inputManager = GetComponent<InputManager>();
		inputManager.localEventManager = localEventManager;
		if(Type!=CharacterType.Player)
		{
			transform.Find("UpBody").GetComponent<AudioListener>().enabled = false;
			inputManager.enabled=false;
		}
		switch (Type) {
		case CharacterType.Player:
			character=new Player(gameObject);
			GameManager.Player=transform.Find("DownCollider").gameObject;
			break;
		case CharacterType.Enemy:
			character=new Enemy(gameObject);
			break;
		}
	}
Ejemplo n.º 25
0
        private bool CanClimb(Vector3 velocity, BoundingBox entityBox, BoundingBox blockBox)
        {
            if (velocity.Y < 0f || velocity.Y > 0f)
            {
                return(false);
            }

            var yDifference = blockBox.Max.Y - entityBox.Min.Y;

            //if (!(blockBox.Max.Y > entityBox.Min.Y))
            //	return false;

            if (yDifference > MaxJumpHeight)
            {
                return(false);
            }

            if (PhysicsManager.GetIntersecting(Entity.Level, entityBox).Any(bb => bb.Min.Y >= entityBox.Min.Y && bb.Min.Y <= entityBox.Max.Y))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 26
0
    //创建
    public virtual void Instance(ItemType type, CubeType cubeType)
    {
        size       = BuildingManager.instance.cubeSize;
        halfSize   = size / 2;
        mtype      = type;
        m_collider = GetComponent <Collider>();
        density    = PhysicsManager.GetDensity(cubeType);
        //如果是默认材质则不需要赋予材质
        if (cubeType == CubeType.none)
        {
            return;
        }

        transform.GetComponent <MeshRenderer>().material = CubeFactory.instance.GetCubeMaterial(cubeType);

        if (m_collider != null)
        {
            m_collider.material = CubeFactory.instance.GetCubePhysicMaterial(cubeType);
        }


        vol    = (transform.localScale.x * transform.localScale.y * transform.localScale.z);
        maxBuo = 1000 * 9.8f * vol;
    }
    public void Initialize(int ind, PhysicsManager m)
    {
        index   = ind;
        Manager = m;

        // Initialize local positions. We assume that the object is connected to a Sphere mesh.
        Transform xform = GetComponent <Transform>();

        if (xform == null)
        {
            System.Console.WriteLine("[ERROR] Couldn't find any transform to the constraint");
        }
        else
        {
            System.Console.WriteLine("[TRACE] Succesfully found transform connected to the constraint");
        }

        // Initialize kinematics
        Vector3 pos = xform.position;

        // Local positions on objects
        pointA = (bodyA != null) ? bodyA.PointGlobalToLocal(pos) : pos;
        pointB = (bodyB != null) ? bodyB.PointGlobalToLocal(pos) : pos;
    }
Ejemplo n.º 28
0
        // 剛体のグローバル座標化
        void GlobalizeRigidbody(GameObject[] joints)
        {
            if ((null != joints) && (0 < joints.Length))
            {
                // 物理演算ルートを生成してルートの子供に付ける
                GameObject     physics_root    = new GameObject("Physics");
                PhysicsManager physics_manager = physics_root.AddComponent <PhysicsManager>();
                physics_root.transform.parent = root_game_object_.transform;
                Transform physics_root_transform = physics_root.transform;

                // PhysicsManagerに移動前の状態を覚えさせる(幾つか重複しているので重複は削除)
                physics_manager.connect_bone_list = joints.Select(x => x.gameObject)
                                                    .Distinct()
                                                    .Select(x => new PhysicsManager.ConnectBone(x, x.transform.parent.gameObject))
                                                    .ToArray();

                //isKinematicで無くConfigurableJointを持つ場合はグローバル座標化
                foreach (ConfigurableJoint joint in joints.Where(x => !x.GetComponent <Rigidbody>().isKinematic)
                         .Select(x => x.GetComponent <ConfigurableJoint>()))
                {
                    joint.transform.parent = physics_root_transform;
                }
            }
        }
Ejemplo n.º 29
0
        public void RayCastMissUp()
        {
            // Arrange
            var box     = new Box2(5, -5, 10, 6);
            var ray     = new Ray(new Vector2(4.99999f, 1), Vector2.UnitY);
            var manager = new PhysicsManager();

            var mock = new Mock <ICollidable>();

            mock.Setup(foo => foo.WorldAABB).Returns(box);
            mock.Setup(foo => foo.Owner).Returns(new Entity()); // requires ICollidable not have null owner
            mock.Setup(foo => foo.CollisionEnabled).Returns(true);
            mock.Setup(foo => foo.CollisionLayer).Returns(0x4);
            mock.Setup(foo => foo.CollisionMask).Returns(0x04);
            manager.AddCollidable(mock.Object);

            // Act
            var result = manager.IntersectRay(ray);

            // Assert
            Assert.That(result.DidHitObject, Is.False);
            Assert.That(result.Distance, Is.EqualTo(0.0f));
            Assert.That(result.HitPos, Is.EqualTo(Vector2.Zero));
        }
Ejemplo n.º 30
0
 public override PhysicsShapeHandle CreatePhysicsShape(out Vector3 shapeOffset)
 {
     if (Math.Abs(ShapeDesc.TopRadius - ShapeDesc.BottomRadius) < MathUtils.FlopsErrorMargin)
     {
         return(PhysicsManager.CreateCylinderShape(ShapeDesc.BottomRadius, ShapeDesc.Height, new CollisionShapeOptionsDesc(Transform.Scale), out shapeOffset));
     }
     else if (Math.Abs(ShapeDesc.TopRadius) < MathUtils.FlopsErrorMargin)
     {
         return(PhysicsManager.CreateConeShape(ShapeDesc.BottomRadius, ShapeDesc.Height, new CollisionShapeOptionsDesc(Transform.Scale), out shapeOffset));
     }
     else
     {
         List <DefaultVertex> outVerts;
         List <uint>          outIndices;
         GetVertexData(out outVerts, out outIndices);
         shapeOffset = Vector3.ZERO;
         return(PhysicsManager.CreateConcaveHullShape(
                    outVerts.Select(df => df.Position),
                    outIndices.Select(@uint => (int)@uint),
                    new CollisionShapeOptionsDesc(Transform.Scale),
                    null
                    ));
     }
 }
Ejemplo n.º 31
0
        static void Main(string[] args)
        {
            InitSettings();

            Window = new Window();
            if (!Window.OpenWindow("Yahtzee Quest", new Size((int)Settings.CurrentScreenSize.x, (int)Settings.CurrentScreenSize.y)))
            {
                return;
            }
            gl = GL.GetApi();
            Window.SetVSync(true);
            Window.OnTick   += Tick;
            Window.OnButton += OnButton;
            Window.OnResize += OnResize;

            SetupGL();

            Properties.Resources.ResourceManager.GetStream("postPro.vert");

            FontRepository = new FontRepository(gl);

            InputManager       = new InputManager();
            PostProcessManager = new PostProcessManager();
            PhysicsManager     = new PhysicsManager();
            CurrentScene       = new SceneLoading();
            Renderer           = new Renderer();

            CurrentScene.Init();
            PostProcessManager.AddPostProcessShader("gammaCorrect");

            Renderer.AddRenderable(CurrentScene);
            Renderer.AddRenderable(PostProcessManager);
            Renderer.AddRenderable(CurrentScene.UI);

            Window.StartLoop();
        }
Ejemplo n.º 32
0
    // Nothing to do here

    #endregion

    #region ISimulable

    public void initialize(int index, PhysicsManager manager)
    {
        m_manager = manager;

        // Initialize indices
        m_index = index;

        // Initialize inertia. We assume that the object is connected to a Cube mesh.
        Transform xform = this.GetComponent <Transform> ();

        if (xform == null)
        {
            System.Console.WriteLine("[ERROR] Couldn't find any transform connected to the rigid body");
        }
        else
        {
            System.Console.WriteLine("[TRACE] Succesfully found transform connected to the rigid body");
        }

        if (xform != null)
        {
            this.m_inertia0 = DenseMatrixXD.CreateIdentity(3);
            double[] vals;
            vals     = new double[3];
            vals [0] = 1.0f / 12.0f * mass * (xform.localScale.y * xform.localScale.y + xform.localScale.z * xform.localScale.z);
            vals [1] = 1.0f / 12.0f * mass * (xform.localScale.x * xform.localScale.x + xform.localScale.z * xform.localScale.z);
            vals [2] = 1.0f / 12.0f * mass * (xform.localScale.x * xform.localScale.x + xform.localScale.y * xform.localScale.y);
            this.m_inertia0.SetDiagonal(vals);
        }

        // Initialize kinematics
        this.m_pos   = xform.position;
        this.m_rot   = xform.rotation;
        this.m_vel   = Vector3.zero;
        this.m_omega = Vector3.zero;
    }
Ejemplo n.º 33
0
        public override void OnUpdate()
        {
            if (CheckInterrupt())
            {
                return;
            }

            PhysicsManager.forceGravity.y = controller.InputManager.GetAxis((int)EntityInputs.Float)
                                            * controller.EntityStats.floatVerticalSpeed;

            if (controller.InputManager.GetAxis2D((int)EntityInputs.Movement).magnitude <= InputConstants.movementMagnitude)
            {
                PhysicsManager.ApplyMovementFriction(controller.EntityStats.floatFriction);
            }
            else
            {
                HandleMovement();
            }

            if (controller.LockedOn)
            {
                controller.RotateVisual(controller.LockonForward, controller.EntityStats.floatLockOnRotationSpeed);
            }
        }
Ejemplo n.º 34
0
 public void Dispose()
 {
     if (!this.IsDisposed)
     {
         Console.WriteLine("Disposing Item Drop Manager");
         this.DestroyAllItemDrops();
         this.m_itemDropsToRemoveList.Clear();
         this.m_itemDropsToRemoveList = null;
         this.m_itemDropPool.Dispose();
         this.m_itemDropPool = null;
         this.m_physicsManager = null;
         this.m_isDisposed = true;
     }
 }
Ejemplo n.º 35
0
 private void Awake()
 {
     instance = this;
 }
Ejemplo n.º 36
0
 public EnemyObj(string spriteName, PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base(spriteName, physicsManager, levelToAttachTo)
 {
 }
Ejemplo n.º 37
0
 public override void Dispose()
 {
     if (!base.IsDisposed)
     {
         Console.WriteLine("Disposing Procedural Level Screen");
         Tween.StopAll(false);
         this.m_currentRoom = null;
         this.DisposeRTs();
         foreach (RoomObj current in this.m_roomList)
         {
             current.Dispose();
         }
         this.m_roomList.Clear();
         this.m_roomList = null;
         this.m_enemyStartPositions.Clear();
         this.m_enemyStartPositions = null;
         this.m_tempEnemyStartPositions.Clear();
         this.m_tempEnemyStartPositions = null;
         this.m_textManager.Dispose();
         this.m_textManager = null;
         this.m_physicsManager = null;
         this.m_projectileManager.Dispose();
         this.m_projectileManager = null;
         this.m_itemDropManager.Dispose();
         this.m_itemDropManager = null;
         this.m_currentRoom = null;
         this.m_miniMapDisplay.Dispose();
         this.m_miniMapDisplay = null;
         this.m_mapBG.Dispose();
         this.m_mapBG = null;
         this.m_inputMap.Dispose();
         this.m_inputMap = null;
         this.m_lastEnemyHit = null;
         this.m_playerHUD.Dispose();
         this.m_playerHUD = null;
         this.m_player = null;
         this.m_enemyHUD.Dispose();
         this.m_enemyHUD = null;
         this.m_impactEffectPool.Dispose();
         this.m_impactEffectPool = null;
         this.m_blackBorder1.Dispose();
         this.m_blackBorder1 = null;
         this.m_blackBorder2.Dispose();
         this.m_blackBorder2 = null;
         this.m_chestList.Clear();
         this.m_chestList = null;
         this.m_projectileIconPool.Dispose();
         this.m_projectileIconPool = null;
         this.m_objKilledPlayer = null;
         this.m_dungeonLight.Dispose();
         this.m_dungeonLight = null;
         this.m_traitAura.Dispose();
         this.m_traitAura = null;
         this.m_killedEnemyObjList.Clear();
         this.m_killedEnemyObjList = null;
         this.m_roomEnteringTitle.Dispose();
         this.m_roomEnteringTitle = null;
         this.m_roomTitle.Dispose();
         this.m_roomTitle = null;
         this.m_creditsText.Dispose();
         this.m_creditsText = null;
         this.m_creditsTitleText.Dispose();
         this.m_creditsTitleText = null;
         Array.Clear(this.m_creditsTextTitleList, 0, this.m_creditsTextTitleList.Length);
         Array.Clear(this.m_creditsTextList, 0, this.m_creditsTextList.Length);
         this.m_creditsTextTitleList = null;
         this.m_creditsTextList = null;
         this.m_filmGrain.Dispose();
         this.m_filmGrain = null;
         this.m_objectivePlate.Dispose();
         this.m_objectivePlate = null;
         this.m_objectivePlateTween = null;
         this.m_sky.Dispose();
         this.m_sky = null;
         this.m_whiteBG.Dispose();
         this.m_whiteBG = null;
         this.m_compassBG.Dispose();
         this.m_compassBG = null;
         this.m_compass.Dispose();
         this.m_compass = null;
         if (this.m_compassDoor != null)
         {
             this.m_compassDoor.Dispose();
         }
         this.m_compassDoor = null;
         this.m_castleBorderTexture.Dispose();
         this.m_gardenBorderTexture.Dispose();
         this.m_towerBorderTexture.Dispose();
         this.m_dungeonBorderTexture.Dispose();
         this.m_neoBorderTexture.Dispose();
         this.m_castleBorderTexture = null;
         this.m_gardenBorderTexture = null;
         this.m_towerBorderTexture = null;
         this.m_dungeonBorderTexture = null;
         this.DebugTextObj.Dispose();
         this.DebugTextObj = null;
         base.Dispose();
     }
 }
Ejemplo n.º 38
0
        /// <summary>
        /// Performs initialisation of the world, such as loading configuration from disk.
        /// </summary>
        public virtual void StartUp()
        {
            this.regionData = new RegionInfo();
            try
            {
                this.localConfig = new XmlConfig(m_config);
                this.localConfig.LoadData();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            m_console.WriteLine("Main.cs:Startup() - Loading configuration");
            this.regionData.InitConfig(this.m_sandbox, this.localConfig);
            this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change


            GridServers = new Grid();
            if (m_sandbox)
            {
                GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
                GridServers.GridDll  = "OpenSim.GridInterfaces.Local.dll";

                m_console.WriteLine("Starting in Sandbox mode");
            }
            else
            {
                if (this.gridLocalAsset)
                {
                    GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
                }
                else
                {
                    GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll";
                }
                GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll";

                m_console.WriteLine("Starting in Grid mode");
            }

            try
            {
                GridServers.Initialise();
            }
            catch (Exception e)
            {
                m_console.WriteLine(e.Message + "\nSorry, could not setup the grid interface");
                Environment.Exit(1);
            }

            startuptime = DateTime.Now;

            try
            {
                AssetCache     = new AssetCache(GridServers.AssetServer);
                InventoryCache = new InventoryCache();
            }
            catch (Exception e)
            {
                m_console.WriteLine(e.Message + "\nSorry, could not setup local cache");
                Environment.Exit(1);
            }

            //should be passing a IGenericConfig object to these so they can read the config data they want from it
            GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey);
            IGridServer gridServer = GridServers.GridServer;

            gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey);

            this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
            this.physManager.LoadPlugins();

            this.CustomiseStartup();

            m_console.WriteLine("Main.cs:Startup() - Initialising HTTP server");
            // HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort);

            BaseHttpServer httpServer       = new BaseHttpServer(regionData.IPListenPort);
            LoginServer    loginServer      = null;
            LoginServer    adminLoginServer = null;

            bool sandBoxWithLoginServer = m_loginserver && m_sandbox;

            if (sandBoxWithLoginServer)
            {
                loginServer = new LoginServer(gridServer, regionData.IPListenAddr, regionData.IPListenPort, regionData.RegionLocX, regionData.RegionLocY, this.user_accounts);
                loginServer.Startup();

                if (user_accounts)
                {
                    //sandbox mode with loginserver using accounts
                    this.GridServers.UserServer = loginServer;
                    adminLoginServer            = loginServer;

                    httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
                }
                else
                {
                    //sandbox mode with loginserver not using accounts
                    httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
                }
            }

            AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer);

            adminWebFront.LoadMethods(httpServer);

            m_console.WriteLine("Main.cs:Startup() - Starting HTTP server");
            httpServer.Start();

            MainServerListener();

            m_heartbeatTimer.Enabled  = true;
            m_heartbeatTimer.Interval = 100;
            m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
        }
Ejemplo n.º 39
0
 public Game(string filePath = "")
 {
     if (filePath.Contains("-t"))
     {
         LevelEV.TESTROOM_LEVELTYPE = GameTypes.LevelType.TOWER;
         filePath = filePath.Replace("-t", "");
     }
     else if (filePath.Contains("-d"))
     {
         LevelEV.TESTROOM_LEVELTYPE = GameTypes.LevelType.DUNGEON;
         filePath = filePath.Replace("-d", "");
     }
     else if (filePath.Contains("-g"))
     {
         LevelEV.TESTROOM_LEVELTYPE = GameTypes.LevelType.GARDEN;
         filePath = filePath.Replace("-g", "");
     }
     if (Thread.CurrentThread.CurrentCulture.Name != "en-US")
     {
         Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", false);
         Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US", false);
     }
     this.m_commandLineFilePath = filePath;
     this.graphics = new GraphicsDeviceManager(this);
     base.Content.RootDirectory = "Content";
     EngineEV.ScreenWidth = 1320;
     EngineEV.ScreenHeight = 720;
     base.Window.Title = "Rogue Legacy";
     Game.ScreenManager = new RCScreenManager(this);
     this.m_saveGameManager = new SaveGameManager(this);
     base.IsFixedTimeStep = false;
     this.graphics.SynchronizeWithVerticalRetrace = !LevelEV.SHOW_FPS;
     base.Window.AllowUserResizing = false;
     if (!LevelEV.ENABLE_OFFSCREEN_CONTROL)
     {
         base.InactiveSleepTime = default(TimeSpan);
     }
     this.m_physicsManager = new PhysicsManager();
     Game.EquipmentSystem = new EquipmentSystem();
     Game.EquipmentSystem.InitializeEquipmentData();
     Game.EquipmentSystem.InitializeAbilityCosts();
     Game.GameConfig = default(Game.SettingStruct);
     Form form = Control.FromHandle(base.Window.Handle) as Form;
     if (form != null)
     {
         form.FormClosing += new FormClosingEventHandler(this.FormClosing);
     }
     this.GraphicsDeviceManager.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(this.ChangeGraphicsSettings);
     SleepUtil.DisableScreensaver();
 }
 public void OnDisable()
 {
     //Potentially creating a memory leak of a single physics manager?
     //Not sure why
     PhysicsManager.GetInstance().RemoveCollider(this);
 }
 public void Start()
 {
     PhysicsManager.GetInstance().AddCollider(this);
 }
Ejemplo n.º 42
0
        public void UpdateMe()
        {
            if (this.MyWorld.IsDirty)
            {
                FOVBasicBoard board = (FOVBasicBoard)m_FOVHandler.Do(this.WorldPosition, this.MyWorld.Dimensions, this.VisionMod, this.MyWorld.Walls.Keys.ToList());
                m_Vision = board.Vision;
            }
            else
            {
                FOVBasicBoard board = (FOVBasicBoard)m_FOVHandler.Do(this.WorldPosition, this.VisionMod);
                m_Vision = board.Vision;
            }

            HasMoved = false;

            if (!PlayerControlled)
            {
                //Attack immediate threats

                /*
                 * REDO THIS TO BE IN LUA
                 * //List<NeedAIData> targets = MyWorld.SearchForEntities(this, "Any", Intent.Attack, EntityTypeSearch.Any, EntitySentienceSearch.Any);
                 * //List<NeedAIData> validTargets = targets.Where(x => this.HasRelationship(x.target.GUID) < ATTACK_THRESHOLD).ToList();
                 * if(validTargets.Count > 0 && CurrentTarget.target == null)
                 * {
                 *  //TODO: Write a threat assessment system
                 *  //For now, choose a random target and go after them
                 *  int result = RNG.Roll(0, validTargets.Count - 1);
                 *  NeedAIData data = validTargets[result];
                 *
                 *  CurrentTarget = data;
                 *  m_PathfindingData = m_Pathfinder.FindPath(this.WorldPosition, CurrentTarget.target.WorldPosition, this.MyWorld);
                 * }
                 */

                //If you're idle
                if (CurrentTarget.idle == true)
                {
                    //Let's find something to do
                    List <EntityNeed> needs = m_Needs.Values.OrderByDescending(x => x.priority).ToList();
                    //Act on first need

                    bool idle = true;
                    foreach (EntityNeed need in needs)
                    {
                        if (need.contributingHappiness)
                        {
                            continue;
                        }

                        Debug.Log("Running LUA script: FindFulfilmentObject (" + need.name + ") requested by: " + this.JoyName);
                        ScriptingEngine.RunScript(need.InteractionFileContents, need.name, "FindFulfilmentObject", new object[] { new MoonEntity(this) });
                        idle = false;
                        break;
                    }
                    m_CurrentTarget.idle = idle;
                }
                //Otherwise, carry on with what you're doing
                else
                {
                    if (WorldPosition == CurrentTarget.targetPoint || (CurrentTarget.target != null && WorldPosition == CurrentTarget.target.WorldPosition))
                    {
                        //If we have a target
                        if (CurrentTarget.target != null)
                        {
                            //We're interacting with an entity here
                            if (CurrentTarget.intent == Intent.Interact)
                            {
                                //TODO: WRITE AN ENTITY INTERACTION
                                EntityNeed need = this.Needs[CurrentTarget.need];

                                Debug.Log("Running LUA script: FindFulfilmentObject (" + need.name + ") requested by: " + this.JoyName);
                                ScriptingEngine.RunScript(need.InteractionFileContents, need.name, "FindFulfilmentObject", new object[] { new MoonEntity(this) });
                            }
                            else if (CurrentTarget.intent == Intent.Attack)
                            {
                                CombatEngine.SwingWeapon(this, CurrentTarget.target);
                            }
                        }
                    }
                    //If we've not arrived at our target
                    else if (WorldPosition != CurrentTarget.targetPoint || (CurrentTarget.target != null && AdjacencyHelper.IsAdjacent(WorldPosition, CurrentTarget.target.WorldPosition) == false))
                    {
                        //Move to target
                        MoveToTarget(CurrentTarget);
                    }
                }
            }
            else
            {
                if (!HasMoved && m_PathfindingData.Count > 0)
                {
                    Vector2Int    nextPoint     = m_PathfindingData.Peek();
                    PhysicsResult physicsResult = PhysicsManager.IsCollision(WorldPosition, nextPoint, MyWorld);
                    if (physicsResult != PhysicsResult.EntityCollision)
                    {
                        m_PathfindingData.Dequeue();
                        Move(nextPoint);
                        HasMoved = true;
                    }
                    else if (physicsResult == PhysicsResult.EntityCollision)
                    {
                        MyWorld.SwapPosition(this, MyWorld.GetEntity(nextPoint));

                        m_PathfindingData.Dequeue();
                        Move(nextPoint);
                        HasMoved = true;
                    }
                }
            }
        }
Ejemplo n.º 43
0
        public static List <Obstacle> randomObstacle(Texture2D[] frames, Vector2 origin, PhysicsManager pm, Vector2 scale, String mask)
        {
            float levelLength = Global.bg.currentLevel.CurrentFrame.Width * Global.scale * (Global.bg.currentLevel.amount - 1); // the ground length

            levelLength -= 2000;                                                                                                // giving the player 100 pixels before he needs to act
            //int obstacleAmount = Tools.rnd.Next((int)levelLength / 10000, (int)levelLength / 5000);
            int             obstacleAmount = (int)(levelLength / 3000);
            List <Obstacle> obstaclesList  = new List <Obstacle>();

            for (int i = 0; i < obstacleAmount; i++)
            {
                //int togather = Tools.rnd.Next(1, 3); // amount of obsticale that can be next to each other
                int togather = 1;
                //Vector2 pos = new Vector2(2000 + Tools.rnd.Next(1500, 2000) * i, Global.bg.currentLevel.groundPos.Y * Global.scale);
                Vector2 pos = new Vector2(2000 + 3000 * i, Global.bg.currentLevel.groundPos.Y * Global.scale);
                for (int t = 0; t < togather; t++)
                {
                    Vector2   tmp  = new Vector2(frames[0].Width * scale.X * t, 0);
                    Texture2D tmp2 = Tools.cm.Load <Texture2D>("obstacle/explosion/Explosion");
                    Tools.makeTransparent(tmp2);
                    obstaclesList.Add(new Obstacle(frames, mask, tmp2
                                                   , Tools.cm.Load <Texture2D>("obstacle/explosion/ExplosionM"), null, -999, null, frames[0], pos + tmp, null, Color.White, 0, origin, scale, SpriteEffects.None, 0, pm));
                }
            }
            return(obstaclesList);
        }
Ejemplo n.º 44
0
 private void Awake()
 {
     PhysicsManager.New(Config);
     PhysicsManager.instance.LockedTimeStep = Config.lockedTimeStep;
     PhysicsManager.instance.Init();
 }
Ejemplo n.º 45
0
        public void OnUpdateFrame(FrameEventArgs e, KeyboardDevice Keyboard, MouseDevice Mouse)
        {
            if (fadingIn)
            {
                fadePercent -= (float)e.Time;
                if (fadePercent <= 0)
                {
                    fadingIn = false;
                }
            }

            if (fadingOut)
            {
                fadePercent += (float)e.Time;
                if (fadePercent >= 1)
                {
                    StateManager.PopState();
                    if (level + 1 > maxLevel)
                    {
                        StateManager.PushState(new MenuState("You escaped!", "\n\n\nPlay again?"));
                    }
                    else
                    {
                        StateManager.PushState(new GameState(level + 1));
                    }
                }
            }

            float time = (float)e.Time;
            bool  up = Keyboard[Key.W], left = Keyboard[Key.A], down = Keyboard[Key.S], right = Keyboard[Key.D];

            player.Update(time);

            Entity prevCollidedWith = lastCollidedWith;

            lastCollidedWith = null;

            Vector2 realPrevPos     = player.Position;

            if (up && left)
            {
                player.MoveUpLeft(time);
            }
            else if (up && right)
            {
                player.MoveUpRight(time);
            }
            else if (down && left)
            {
                player.MoveDownLeft(time);
            }
            else if (down && right)
            {
                player.MoveDownRight(time);
            }
            else if (up)
            {
                player.MoveUp(time);
            }
            else if (left)
            {
                player.MoveLeft(time);
            }
            else if (down)
            {
                player.MoveDown(time);
            }
            else if (right)
            {
                player.MoveRight(time);
            }
            else
            {
                lastCollidedWith = prevCollidedWith;                 //if no key was pressed, restore the old one. HACK
                player.moving    = false;
            }

            if (map.IsColliding(player.BoundingBox))
            {
                player.Position = realPrevPos;
            }

            foreach (var ent in entities)
            {
                if (ent is Pickaxe)
                {
                    ((Pickaxe)ent).AIUpdate(player);
                }

                if (ent is Goblin)
                {
                    ((Goblin)ent).AIUpdate(player);
                }
            }

            for (int i = entities.Count - 1; i >= 0; i--)
            {
                Entity ent = entities[i];

                ent.Update(time);
                if (map.IsColliding(ent.BoundingBox))
                {
                    ent.ResetPos();
                }

                if (PhysicsManager.IsColliding(player.BoundingBox, ent.BoundingBox))
                {
                    lastCollidedWith = ent;

                    if (ent is Generator)
                    {
                        player.Position = realPrevPos;
                    }
                    else if (ent is Lift)
                    {
                        if (((Lift)ent).enabled)
                        {
                            ((Lift)ent).source.Play();
                            fadingOut = true;
                        }
                    }
                    else if (ent is Pickaxe)
                    {
                        if (((Pickaxe)ent).active)
                        {
                            entities.Remove(ent);
                            player.health--;
                        }
                    }
                    else if (ent is Goblin)
                    {
                        entities.Remove(ent);
                        player.health -= 2;
                    }
                    else if (ent is Endgame)
                    {
                        fadingOut = true;
                    }
                }
            }

            if (Keyboard[Key.E] && lastCollidedWith != null)
            {
                if (lastCollidedWith is Generator)
                {
                    ((Generator)lastCollidedWith).Used = true;
                    player.drawShadow = false;
                    lift.Enable();
                }
            }

            camera.Position          = player.Position;
            AudioManager.ListenerPos = new Vector3(player.Position);

            if (generator != null && generator.Used)
            {
                for (int i = entities.Count - 1; i >= 0; i--)
                {
                    var ent = entities[i];
                    if (ent is Goblin)
                    {
                        entities.Remove(ent);
                    }
                    if (ent is Pickaxe)
                    {
                        ((Pickaxe)ent).active = false;
                    }
                }
            }

            if (player.health <= 0)
            {
                StateManager.PopState();
                StateManager.PushState(loseState);
            }
        }
Ejemplo n.º 46
0
 private void Act()
 {
     Result = PhysicsManager.CollidesOnMask(A.Object, B.Object);
 }
Ejemplo n.º 47
0
        /// <summary>
        /// Draw whats needed this frame
        /// </summary>
        /// <param name="gameTime">Current Game Time</param>
        /// <param name="spriteBatch">Sprite Batch</param>
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, GraphicsDevice graphicsDevice)
        {
            //Create waypoint texture
            if (waypointTex == null)
            {
                waypointTex = new Texture2D(graphicsDevice, 1, 1);
                waypointTex.SetData(new Color[] { Color.White });
            }

            if (CameraRef.IsInViewport(this))
            {
                spriteBatch.Draw(enemyTexture, Position, null, Color.White, Rotation.Z, Vector2.Zero, Scale, SpriteEffects.None, 0.0f);
            }
            else
            {
                //Draw an arrow pointing to our location
                Vector2 midpoint  = CameraRef.GetViewportMid();
                Vector2 direction = midpoint - Position;

                Vector2?offscreenAnchor = null;
                if (//Top of Viewport
                    (offscreenAnchor = PhysicsManager.FindLineIntersection(midpoint, Position, CameraRef.Position, CameraRef.Position + new Vector2(CameraRef.Viewport.X, 0))).HasValue ||
                    //Bottom of Viewport
                    (offscreenAnchor = PhysicsManager.FindLineIntersection(midpoint, Position, CameraRef.Position + new Vector2(0, CameraRef.Viewport.Y), CameraRef.Position + CameraRef.Viewport)).HasValue ||
                    //Right of Viewport
                    (offscreenAnchor = PhysicsManager.FindLineIntersection(midpoint, Position, CameraRef.Position + new Vector2(CameraRef.Viewport.X, 0), CameraRef.Position + CameraRef.Viewport)).HasValue ||
                    //Left of Viewport
                    (offscreenAnchor = PhysicsManager.FindLineIntersection(midpoint, Position, CameraRef.Position, CameraRef.Position + new Vector2(0, CameraRef.Viewport.Y))).HasValue)
                {
                    //Draw a line at the direction angle
                    Vector2 offscreenAngle = offscreenAnchor.Value - Position;
                    float   offscreenRot   = (float)Math.Atan2(offscreenAngle.Y, offscreenAngle.X);

                    offscreenAngle.Normalize();

                    //Draw indicator
                    spriteBatch.Draw(offscreenTex, offscreenAnchor.Value + (offscreenAngle * OffscreenIndicatorOffset), null, Color.White, offscreenRot, new Vector2(0, offscreenTex.Height / 2), new Vector2(1), Math.Abs(offscreenRot) > (Math.PI / 2) ? SpriteEffects.FlipVertically : SpriteEffects.None, 0.006f);
                }
            }

            //Debug Draw
            if (GameManager.DebugMode && currentPath != null && currentPath.Count > 0)
            {
                spriteBatch.DrawString(debugFont, CurrentMovingState.ToString(), new Vector2(Position.X, Position.Y - 25), Color.Red);

                //Draw his planned path in red
                WaypointNode prevNode = NextNode;
                spriteBatch.Draw(waypointTex, new Rectangle((int)prevNode.Position.X - 3, (int)prevNode.Position.Y - 3, 6, 6), Color.Yellow);
                foreach (WaypointNode node in currentPath)
                {
                    //Draw Waypoints
                    spriteBatch.Draw(waypointTex, new Rectangle((int)node.Position.X - 3, (int)node.Position.Y - 3, 6, 6), Color.Red);

                    Vector2 waypointLine = node.Position - prevNode.Position;
                    float   lineAngle    = (float)Math.Atan2(waypointLine.Y, waypointLine.X);

                    spriteBatch.Draw(waypointTex,
                                     new Rectangle((int)prevNode.Position.X, (int)prevNode.Position.Y, (int)waypointLine.Length(), 2),
                                     null,
                                     prevNode == NextNode ? Color.Yellow : Color.Red,
                                     lineAngle,
                                     new Vector2(0, 0),
                                     SpriteEffects.None,
                                     0);

                    prevNode = node;
                }
            }

            base.Draw(gameTime, spriteBatch, graphicsDevice);
        }
Ejemplo n.º 48
0
    public void Update()
    {
        if (Sleep || Collision == null)
        {
            return;
        }

        /*
         * if (trace) {
         *  position = oldPos;
         *  velocity = oldVel;
         *  trace = false;
         *  return;
         * }*/

        var offset = TileDataProvider.WorldPosToOffsetTile(position);
        //GetBottomPos

        bool isWater      = MapGenerator.GetTile(offset).IsWater2();
        var  offsetBottom = TileDataProvider.WorldPosToOffsetTile(GetBottomPos());
        bool isStairs     = MapGenerator.GetTile(offsetBottom).IsStairs();



        float d = isWater ? 2 : 1;

        oldVel = velocity;

        //Эффект поплавка например не тонуть  в воде
        //d = gravity.y;

        if (isWater && velocity.y >= -5)
        {
            velocity += gravity / d;
        }
        else
        {
            if (!isWater)
            {
                velocity += gravity / d;
            }

            if (isWater && velocity.y < -5)
            {
                velocity = new Vector2(velocity.x, -5);
            }
        }

        velocity = new Vector2(velocity.x * momentVector.x, velocity.y * momentVector.y);

        if (isStairs)
        {
            bool isStairsCenter = MapGenerator.GetTile(offset).IsStairs();

            if (!isStairsCenter && velocity.y < 0)
            {
                velocity = new Vector2(velocity.x, 0);
            }
            if (isStairsCenter)
            {
                velocity = new Vector2(velocity.x, 0);
            }
        }

        //урезаем
        oldVelocity = velocity;


        var newVelocity = velocity;

        if (IsCollisionTerrain)
        {
            newVelocity = Collision.ChackVelocity(position, velocity, itemWidth, itemHeight);
        }

        if (velocity != newVelocity)
        {
            OnTerrainCollision.TryCall();
        }

        velocity  = newVelocity;
        oldPos    = position;
        position += velocity;
        if (ReboundFactor != 0)
        {
            if (Math.Abs(oldVelocity.x - velocity.x) > 0.1f)
            {
                velocity = new Vector2(-oldVelocity.x * ReboundFactor, velocity.y);
            }

            if (Math.Abs(oldVelocity.y - velocity.y) > 0.1f)
            {
                velocity = new Vector2(velocity.x, -oldVelocity.y * ReboundFactor);
            }
        }

        PhysicsManager.ChackRect(this);

        if (Vector2.Distance(oldPos, position) == 0)
        {
            countTrySleep++;
            if (countTrySleep > 10)
            {
                Sleep = true;
            }
        }
        else
        {
            countTrySleep = 0;
        }

        /*
         * var offset = TileDataProvider.WorldPosToOffsetTile(position);
         * if (!MapGenerator.GetMap()[offset.x, offset.y].IsEmpty()) {
         *  if (View.name.IndexOf("block") != -1) {
         *      Debug.LogError("type != 0" + View.name + "oldPos = " + oldPos + " position = " + position);
         *      trace = true;
         *  }
         * }*/
    }
Ejemplo n.º 49
0
 void Start()
 {
     physManager = GetComponent <PhysicsManager>();
 }
Ejemplo n.º 50
0
 public override void Physics(PhysicsManager physicsManager)
 {
     physicsManager.Add(player);
 }
Ejemplo n.º 51
0
 // Use this for initialization
 private void Awake()
 {
     physicsManager = GetComponent <PhysicsManager>();
 }
Ejemplo n.º 52
0
 public EnemyObj_Starburst(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemyStarburstIdle_Character", target, physicsManager, levelToAttachTo, difficulty)
 {
     this.Type = 31;
 }
Ejemplo n.º 53
0
        private void UpdateCenterOfMass()
        {
            Vector3 centerMass = PhysicsManager.SeekCenterMass(CollectionHelper.Select(items.ToArray(), p => p.GetParticle()), CollectionHelper.Select(items.ToArray(), p => p.GetMass()));

            localCenterOfMass = new Vector3((float)Math.Round((centerMass - transform.position).x, 2), (float)Math.Round((centerMass - transform.position).y, 2), (float)Math.Round((centerMass - transform.position).z, 2));
        }
Ejemplo n.º 54
0
 public ItemDropManager(int poolSize, PhysicsManager physicsManager)
 {
 }
Ejemplo n.º 55
0
 public Level()
 {
     physics = new PhysicsManager();
 }
Ejemplo n.º 56
0
        //---------------------------------------------------------------------------

        public override void OnCleanup()
        {
            PhysicsManager.Get().World.RemoveBody(Body);
        }
Ejemplo n.º 57
0
 public EnemyTemplate(PlayerObj target, PhysicsManager physicsManager, ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty)
     : base("EnemySpriteNameGoesHere", target, physicsManager, levelToAttachTo, difficulty)
 {
 }
 private void Awake()
 {
     physicsManager = transform.parent.GetComponent <PhysicsManager>();
 }
Ejemplo n.º 59
0
 public ContactPointVisualizer(PhysicsManager pm)
 {
     this.pm = pm;
 }
Ejemplo n.º 60
0
 public override void LoadContent()
 {
     this.DebugTextObj = new TextObj(Game.JunicodeFont);
     this.DebugTextObj.FontSize = 26f;
     this.DebugTextObj.Align = Types.TextAlign.Centre;
     this.DebugTextObj.Text = "";
     this.DebugTextObj.ForceDraw = true;
     this.m_projectileIconPool = new ProjectileIconPool(200, this.m_projectileManager, base.ScreenManager as RCScreenManager);
     this.m_projectileIconPool.Initialize();
     this.m_textManager.Initialize();
     this.m_impactEffectPool.Initialize();
     this.m_physicsManager = (base.ScreenManager.Game as Game).PhysicsManager;
     this.m_physicsManager.SetGravity(0f, 1830f);
     this.m_projectileManager.Initialize();
     this.m_physicsManager.Initialize(base.ScreenManager.Camera);
     this.m_itemDropManager = new ItemDropManager(600, this.m_physicsManager);
     this.m_itemDropManager.Initialize();
     this.m_playerHUD = new PlayerHUDObj();
     this.m_playerHUD.SetPosition(new Vector2(20f, 40f));
     this.m_enemyHUD = new EnemyHUDObj();
     this.m_enemyHUD.Position = new Vector2((float)(660 - this.m_enemyHUD.Width / 2), 20f);
     this.m_miniMapDisplay.SetPlayer(this.m_player);
     this.m_miniMapDisplay.InitializeAlphaMap(new Rectangle(1070, 50, 200, 100), base.Camera);
     this.InitializeAllRooms(true);
     this.InitializeEnemies();
     this.InitializeChests(true);
     this.InitializeRenderTargets();
     this.m_mapBG = new SpriteObj("MinimapBG_Sprite");
     this.m_mapBG.Position = new Vector2(1070f, 50f);
     this.m_mapBG.ForceDraw = true;
     this.UpdateCamera();
     this.m_borderSize = 100;
     this.m_blackBorder1 = new SpriteObj("Blank_Sprite");
     this.m_blackBorder1.TextureColor = Color.Black;
     this.m_blackBorder1.Scale = new Vector2(1340f / (float)this.m_blackBorder1.Width, (float)(this.m_borderSize / this.m_blackBorder1.Height));
     this.m_blackBorder2 = new SpriteObj("Blank_Sprite");
     this.m_blackBorder2.TextureColor = Color.Black;
     this.m_blackBorder2.Scale = new Vector2(1340f / (float)this.m_blackBorder2.Width, (float)(this.m_borderSize / this.m_blackBorder2.Height));
     this.m_blackBorder1.ForceDraw = true;
     this.m_blackBorder2.ForceDraw = true;
     this.m_blackBorder1.Y = (float)(-(float)this.m_borderSize);
     this.m_blackBorder2.Y = 720f;
     this.m_dungeonLight = new SpriteObj("LightSource_Sprite");
     this.m_dungeonLight.ForceDraw = true;
     this.m_dungeonLight.Scale = new Vector2(12f, 12f);
     this.m_traitAura = new SpriteObj("LightSource_Sprite");
     this.m_traitAura.ForceDraw = true;
     this.m_objectivePlate = new ObjContainer("DialogBox_Character");
     this.m_objectivePlate.ForceDraw = true;
     TextObj textObj = new TextObj(Game.JunicodeFont);
     textObj.Position = new Vector2(-400f, -60f);
     textObj.OverrideParentScale = true;
     textObj.FontSize = 10f;
     textObj.Text = "Fairy Chest Objective:";
     textObj.TextureColor = Color.Red;
     textObj.OutlineWidth = 2;
     this.m_objectivePlate.AddChild(textObj);
     TextObj textObj2 = new TextObj(Game.JunicodeFont);
     textObj2.OverrideParentScale = true;
     textObj2.Position = new Vector2(textObj.X, textObj.Y + 40f);
     textObj2.ForceDraw = true;
     textObj2.FontSize = 9f;
     textObj2.Text = "Reach the chest in 15 seconds:";
     textObj2.WordWrap(250);
     textObj2.OutlineWidth = 2;
     this.m_objectivePlate.AddChild(textObj2);
     TextObj textObj3 = new TextObj(Game.JunicodeFont);
     textObj3.OverrideParentScale = true;
     textObj3.Position = new Vector2(textObj2.X, textObj2.Y + 35f);
     textObj3.ForceDraw = true;
     textObj3.FontSize = 9f;
     textObj3.Text = "Time Remaining:";
     textObj3.WordWrap(250);
     textObj3.OutlineWidth = 2;
     this.m_objectivePlate.AddChild(textObj3);
     this.m_objectivePlate.Scale = new Vector2(250f / (float)this.m_objectivePlate.GetChildAt(0).Width, 130f / (float)this.m_objectivePlate.GetChildAt(0).Height);
     this.m_objectivePlate.Position = new Vector2(1470f, 250f);
     SpriteObj spriteObj = new SpriteObj("Blank_Sprite");
     spriteObj.TextureColor = Color.Red;
     spriteObj.Position = new Vector2(textObj2.X, textObj2.Y + 20f);
     spriteObj.ForceDraw = true;
     spriteObj.OverrideParentScale = true;
     spriteObj.ScaleY = 0.5f;
     this.m_objectivePlate.AddChild(spriteObj);
     SpriteObj spriteObj2 = new SpriteObj("Blank_Sprite");
     spriteObj2.TextureColor = Color.Red;
     spriteObj2.Position = new Vector2(textObj2.X, spriteObj.Y + 35f);
     spriteObj2.ForceDraw = true;
     spriteObj2.OverrideParentScale = true;
     spriteObj2.ScaleY = 0.5f;
     this.m_objectivePlate.AddChild(spriteObj2);
     base.LoadContent();
     this.m_sky = new SkyObj(this);
     this.m_sky.LoadContent(base.Camera);
     this.m_whiteBG = new SpriteObj("Blank_Sprite");
     this.m_whiteBG.Opacity = 0f;
     this.m_whiteBG.Scale = new Vector2(1320f / (float)this.m_whiteBG.Width, 720f / (float)this.m_whiteBG.Height);
     this.m_filmGrain = new SpriteObj("FilmGrain_Sprite");
     this.m_filmGrain.ForceDraw = true;
     this.m_filmGrain.Scale = new Vector2(2.015f, 2.05f);
     this.m_filmGrain.X -= 5f;
     this.m_filmGrain.Y -= 5f;
     this.m_filmGrain.PlayAnimation(true);
     this.m_filmGrain.AnimationDelay = 0.0333333351f;
     this.m_compassBG = new SpriteObj("CompassBG_Sprite");
     this.m_compassBG.ForceDraw = true;
     this.m_compassBG.Position = new Vector2(660f, 90f);
     this.m_compassBG.Scale = Vector2.Zero;
     this.m_compass = new SpriteObj("Compass_Sprite");
     this.m_compass.Position = this.m_compassBG.Position;
     this.m_compass.ForceDraw = true;
     this.m_compass.Scale = Vector2.Zero;
     this.InitializeCreditsText();
 }