/// <summary>
 /// Remove a physics object from the manager if is present in the manager
 /// </summary>
 /// <param name="rigid"></param>
 public void RemoveCustomPhysics(CustomPhysics2D rigid)
 {
     if (allCustomPhysicsObjectsList.Contains(rigid))
     {
         allCustomPhysicsObjectsList.Remove(rigid);
     }
 }
 /// <summary>
 /// Add a physics object to the manager.
 /// </summary>
 /// <param name="rigid"></param>
 public void AddCustomPhysics(CustomPhysics2D rigid)
 {
     if (allCustomPhysicsObjectsList.Contains(rigid))
     {
         return;
     }
     allCustomPhysicsObjectsList.Add(rigid);
 }
 private void OnValidate()
 {
     if (!rigid)
     {
         rigid = GetComponent <CustomPhysics2D>();
     }
     rigid.useGravity = simulateGravity;
 }
示例#4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="PhysicsComponent"></param>
 /// <returns></returns>
 public void RemoveCustomPhysics(CustomPhysics2D PhysicsComponent)
 {
     if (!AllActivePhysicsComponents.Remove(PhysicsComponent))
     {
         Debug.LogWarning("The physics component that was passed in was not found in our physics manager. This may mean that you already removed it or it was never added.");
         return;
     }
 }
示例#5
0
 public void AddCustomPhysics(CustomPhysics2D PhysicsComponent)
 {
     if (!AllActivePhysicsComponents.Add(PhysicsComponent))
     {
         Debug.LogWarning("You are trying to add a physics component that was already assigned to our Physics Manager.");
         return;
     }
 }
示例#6
0
    private void Awake()
    {
        rigid = GetComponent <CustomPhysics2D>();
        anim  = GetComponent <Animator>();
        currentJumpsAvailable = maxAvailableJumps;

        rigid.OnGroundedEvent += this.OnGroundedEvent;
        rigid.OnAirborneEvent += this.OnAirborneEvent;
    }
示例#7
0
 private void OnValidate()
 {
     if (!rigid)
     {
         rigid = GetComponent <CustomPhysics2D>();
     }
     jumpVelocity           = 2 * jumpHeight / timeToHeight;
     rigid.gravityScale     = jumpVelocity / timeToHeight / CustomPhysics2D.GRAVITY;
     rigid.terminalVelocity = jumpVelocity * rigid.fallingMultiplier;
 }
示例#8
0
    private void Start()
    {
        mainTarget             = this.transform.parent;
        targetRigidbodyPhysics = mainTarget.GetComponent <CustomPhysics2D>();
        cameraOffset           = this.transform.position - mainTarget.position;
        this.transform.SetParent(null);
        associatedCamera = GetComponentInChildren <Camera>();

        GameOverseer.Instance.AddObjectToDontDestroyOnLoad(this.gameObject);
    }
 private void OnValidate()
 {
     if (!rigid)
     {
         rigid = GetComponent <CustomPhysics2D>();
     }
     SetSpriteFlipped(isFacingRight);
     InitializeMovementParameters();
     timeToReachJumpApex = Mathf.Max(.05f, timeToReachJumpApex);
 }
 protected virtual void Awake()
 {
     GameOverseer.Instance.PhysicsManager.AddCollider2DToPhysicsManager(this);
     AssociatedPhysicsComponent = GetComponent <CustomPhysics2D>();
     if (AssociatedPhysicsComponent && AssignedCollisionType != ECollisionType.PHYSICS)
     {
         Debug.LogWarning("Your collider contains a physics component, but is not set to CollisionType - 'Physics'. Are you sure this is correct?");
     }
     else if (!AssociatedPhysicsComponent && AssignedCollisionType == ECollisionType.PHYSICS)
     {
         Debug.LogWarning("You collider does not contain a Physics component, but is assigned to CollisionType - 'Physics'. This can not work");
     }
     PreviousBounds = CollisionFactory.GetNewBoundsInstance(AssociatedBounds.CollisionShape);
     UpdateColliderBounds();                          //We want to update the collider bounds on awake
     PreviousBounds.CopyBoundsFrom(AssociatedBounds); //Make an exact copy for the first iteration
 }
    private void Awake()
    {
        rigid = GetComponent <CustomPhysics2D>();
        anim  = GetComponent <Animator>();

        currentJumpsAvailable = maxAvailableJumps;

        rigid.OnGroundedEvent += this.OnGroundedEvent;
        rigid.OnAirborneEvent += this.OnAirborneEvent;

        CommandInterpreter commandInterpreter = GetComponent <CommandInterpreter>();

        if (commandInterpreter != null)
        {
            commandInterpreter.OnDirectionSetEvent += JoystickDirectionSet;
        }
        InitializeMovementParameters();
    }
示例#12
0
    private void OnValidate()
    {
        if (!rigid)
        {
            rigid = GetComponent <CustomPhysics2D>();
        }
        SetSpriteFlipped(isFacingRight);

        float gravity = (2 * heightOfJump) / Mathf.Pow(timeToReachJumpApex, 2);

        jumpVelocity        = Mathf.Abs(gravity) * timeToReachJumpApex;
        jumpingAcceleration = gravity / CustomPhysics2D.GRAVITY_CONSTANT;
        rigid.gravityScale  = jumpingAcceleration;

        if (maxAvailableJumps < 0)
        {
            maxAvailableJumps = 0;
        }

        if (maximumAirSpeed < 0)
        {
            maximumAirSpeed = 0;
        }
    }
 protected void Start()
 {
     physicsCollider = GetComponent <BoxCollider2D>();
     rigid           = GetComponent <CustomPhysics2D>();
 }
示例#14
0
 protected virtual void Awake()
 {
     rigid = GetComponent <CustomPhysics2D>();
     projectileHitbox.onHurtboxEnteredEvent.AddListener(HitEnemy);
 }
 private void Awake()
 {
     rigid = GetComponent <CustomPhysics2D>();
 }
示例#16
0
 private void Awake()
 {
     rigid = GetComponent <CustomPhysics2D>();
     associatedInteractionHandler = GetComponent <ProjectileInteractionHandler>();
     //associatedInteractionHandler.AssociatedCharacterStats = associatedCharacterStats;
 }
示例#17
0
 private void Start()
 {
     rigid              = GetComponent <CustomPhysics2D>();
     jumpVelocity       = 2 * jumpHeight / timeToHeight;
     rigid.gravityScale = jumpVelocity / timeToHeight / CustomPhysics2D.GRAVITY;
 }
 private void Start()
 {
     rigid = GetComponent <CustomPhysics2D>();
     anim  = GetComponent <Animator>();
 }
示例#19
0
 private void Awake()
 {
     rigid = GetComponent <CustomPhysics2D>();
     associatedCollider = GetComponent <Collider2D>();
 }