示例#1
0
 private void OnGroundCollisionHandler(GroundCollision collision)
 {
     if (collision)
     {
         PlatformCollider coll = collision.collider.GetComponent <PlatformCollider>();
         platform = coll?.platform;
     }
 }
示例#2
0
        public MovingPlatofrm(Layer layer, Vector2 position, float width, bool looped, float pathSpeed, List <Vector2> pathPoints) : base(layer)
        {
            Width = width;

            var cPosition = new PositionComponent(position);
            var cSolid    = new SolidComponent();

            var collider = new PlatformCollider();

            collider.Size   = new Vector2(width * BaseSize, BaseSize / HeightDivider);
            cSolid.Collider = collider;

            var cPath = new PathComponent();

            cPath.Position = cPosition.Position;
            cPath.Points   = pathPoints;
            cPath.Speed    = pathSpeed;
            cPath.Looped   = looped;

            AddComponent(cPosition);
            AddComponent(cSolid);
            AddComponent(cPath);
        }
        /// <summary>
        /// Returns collider for a given tile and sets an offset.
        /// </summary>
        ICollider GetCollider(TiledMapTilesetTile tiledTile, Tileset tileset, ref Vector2 colliderOffset)
        {
            ICollider collider = null;

            if (tiledTile.Objects.Length > 0 && tiledTile.Objects[0] is TiledRectangleObject)
            {
                var obj = tiledTile.Objects[0];

                if (obj.Type.ToLower() == _rectangleName)
                {
                    collider      = new RectangleCollider();
                    collider.Size = obj.Size;
                }
                if (obj.Type.ToLower() == _platformName)
                {
                    collider      = new PlatformCollider();
                    collider.Size = obj.Size;
                }
                // Here we need to flip y in the offset, because tiles are draw with origin in bottom left corner,
                // but colliders take origin as top left corner. Why? Ask Tiled dev.
                colliderOffset = obj.Position + tileset.Offset * new Vector2(1, -1) + obj.Size / 2;
            }
            return(collider);
        }
 protected virtual void Awake()
 {
     //get the reference of playmaker fsms.
     PlayMakerFSM[] fsms = GetComponents<PlayMakerFSM>();
     foreach (PlayMakerFSM fsm in fsms) {
         if (fsm.FsmName == "FSM_Control") {
             FSM_Control = fsm;
         }
         if (fsm.FsmName == "FSM_Hit") {
             FSM_Hit = fsm;
         }
         if (fsm.FsmName == "FSM_Charge") {
             FSM_Charge = fsm;
         }
     }
     //initialize key variables.
     player = transform.GetComponent<PlayerBase>();
     layer = GetComponent<exLayer>();
     velocity = new Vector2(0, 0);
     comboLevel = 0;
     charMoveDir = MoveDir.Stop;
     downButton = BtnHoldState.None;
     initJumpSpeedStatic = jumpSpeed;
     initMoveSpeedStatic = moveSpeed;
     initAttackPowerStatic = attackPower;
     initInvincibleDuration = FSM_Hit.FsmVariables.GetFsmFloat("varInvincibleDuration").Value;
     currentPlatform = Game.instance.theBasePlatform;
 }
示例#5
0
 public void UpdateMoveConstraint(PlatformCollider _platform)
 {
     currentPlatform = _platform;
 }