示例#1
0
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (collider.direction == RC_Direction.DOWN)
     {
         character.Velocity = new Vector3(character.Velocity.x, springForce);
     }
 }
示例#2
0
 /// <summary>
 /// Stand on a respawn point to activate it. You could play a particle effect of something here.
 /// </summary>
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (collider.direction == RC_Direction.DOWN)
     {
         currentRespawnPoint = this;
     }
 }
示例#3
0
 public override void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (character.StartedClimbing) {
         // Swing rope
         if (character.characterInput.x > 0.0f && control.LastSwingDirection <= 0.0f) {
             swingForce = new Vector3(Mathf.Abs (Mathf.Cos(Mathf.Deg2Rad * myTransform.rotation.eulerAngles.z)) * character.climbing.ropeSwingForce, 0.0f, 0.0f);
             control.LastSwingDirection = 1;
             control.hasSwung = true;
         } else if (character.characterInput.x < 0.0f && control.LastSwingDirection >= 0.0f) {
             swingForce = new Vector3(Mathf.Abs (Mathf.Cos(Mathf.Deg2Rad * myTransform.rotation.eulerAngles.z)) * character.climbing.ropeSwingForce * -1, 0.0f, 0.0f);
             control.LastSwingDirection = -1;
             control.hasSwung = true;
         }
         // Move up and down rope
         if (!control.hasClimbed) {
             Vector2 climbForce = Vector2.zero;
             if (character.characterInput.y  > 0.0f) {
                 control.hasClimbed = true;
                 climbForce.y = character.climbing.speed * RaycastCharacterController.FrameTime;
             } else if (character.characterInput.y < 0.0f) {
                 control.hasClimbed = true;
                 climbForce.y = -1 * character.climbing.speed * RaycastCharacterController.FrameTime;
             }
             character.transform.Translate(0.0f, Vector2.Dot(climbForce, myTransform.rotation * Vector2.up), 0.0f, Space.Self);
             float delta = myTransform.position.x - character.transform.position.x;
             character.transform.Translate(RaycastCharacterController.FrameTime * delta, 0.0f, 0.0f, Space.Self);
         }
     }
 }
示例#4
0
 public void OnRaycastClick(RaycastCollider collider, int mouseButton)
 {
     if (highlight)
     {
         OnClick(mouseButton);
     }
 }
 public override void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (collider.direction == RC_Direction.DOWN) {
         characterIsOnMe = true;
         standTimer = standTime;
     }
 }
 public override void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (collider.direction == RC_Direction.DOWN && !fallStarted) {
         fallStarted = true;
         StartCoroutine(Fall());
     }
 }
示例#7
0
	override public void DoAction(RaycastCollider collider, RaycastCharacterController character) {
		// If we are standing on this
		if (!alreadyAdded && collider.direction == RC_Direction.DOWN) {
			character.SetDrag(drag);
			alreadyAdded = true;
		}
	}
示例#8
0
	override public void DoAction(RaycastCollider collider, RaycastCharacterController character) {
		if (character.StartedClimbing) {
			// Move off ladder
			if (control.dismountWithArrows && character.characterInput.x != 0.0f) {
				character.Dismount(this);
			}
		} 
	}
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (collider.direction == RC_Direction.DOWN && !fallStarted)
     {
         fallStarted = true;
         StartCoroutine(Fall());
     }
 }
示例#10
0
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (character.FallThroughTimer <= 0.0f && collider.direction == RC_Direction.DOWN && character.characterInput.y < 0.0f && (!requireJump || character.characterInput.jumpButtonDown))
     {
         character.FallThroughTimer = fallThroughTime;
         character.characterInput.CancelJump();
     }
 }
示例#11
0
	override public void DoAction(RaycastCollider collider, RaycastCharacterController character) {
		// Hitting from below
		if (collider.direction == RC_Direction.UP) {
			if (particles != null) particles.Play();
			myCollider.enabled = false;
			myRenderer.enabled = false;
		}
	}
示例#12
0
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (collider.direction == RC_Direction.DOWN)
     {
         characterIsOnMe = true;
         standTimer      = standTime;
     }
 }
示例#13
0
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     // If we are standing on this
     if (!alreadyAdded && collider.direction == RC_Direction.DOWN)
     {
         character.SetDrag(drag);
         alreadyAdded = true;
     }
 }
示例#14
0
 public void OnRaycastEnter(RaycastCollider collider)
 {
     if (!highlight)
     {
         OnPointerEnter();
         highlight = true;
     }
     hitCount++;
 }
示例#15
0
 public void OnRaycastExit(RaycastCollider collider)
 {
     hitCount--;
     if (highlight && hitCount <= 0)
     {
         OnPointerExit();
         highlight = false;
     }
 }
示例#16
0
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (character.StartedClimbing)
     {
         // Move off ladder
         if (control.dismountWithArrows && character.characterInput.x != 0.0f)
         {
             character.Dismount(this);
         }
     }
 }
示例#17
0
	override public void DoAction(RaycastCollider collider, RaycastCharacterController character) {
		// Hitting from below (i.e. a headbutt)
		if (isActive && collider.direction == RC_Direction.UP) {
			StartCoroutine(DoHit());
			if (spawnGameObject != null && !hasSpawned) StartCoroutine(DoSpawn());
			else if (spawnGameObject != null) DoBobble();
		}
		// Kill enemies above 
		else if (!isActive && collider.direction == RC_Direction.DOWN && character is IEnemy) {
			((IEnemy)character).Kill();
		}
	}
示例#18
0
 /// <summary>
 /// Stand on a respawn point to activate it. You could play a particle effect of something here.
 /// </summary>
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (RespawnPoint.currentRespawnPoint is RespawnFlag2DTK)
     {
         ((RespawnFlag2DTK)RespawnPoint.currentRespawnPoint).Down();
     }
     if (collider.direction == RC_Direction.DOWN)
     {
         RespawnPoint.currentRespawnPoint = this;
     }
     sprite.SetSprite(sprite.GetSpriteIdByName(flagUpSprite));
 }
 /// <summary>
 /// When hit from the sides latch the character (unless we have a box on top of us).
 /// </summary>
 public override void DoAction(RaycastCollider collider, RaycastCharacterController controller)
 {
     if (!BoxOnTop) {
         if (collider.direction == RC_Direction.LEFT) {
             Latch(controller, RC_Direction.LEFT);
         } else if (collider.direction == RC_Direction.RIGHT) {
             Latch(controller, RC_Direction.RIGHT);
         }
     } else {
         UnLatch();
     }
 }
示例#20
0
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     // Hitting from below
     if (collider.direction == RC_Direction.UP)
     {
         if (particles != null)
         {
             particles.Play();
         }
         myCollider.enabled = false;
         myRenderer.enabled = false;
     }
 }
示例#21
0
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     // Hitting from below (i.e. a headbutt)
     if (isActive && collider.direction == RC_Direction.UP)
     {
         StartCoroutine(DoHit());
         if (spawnGameObject != null && !hasSpawned)
         {
             DoSpawn();
         }
     }
     // Kill enemies above
     else if (!isActive && collider.direction == RC_Direction.DOWN && character is IEnemy)
     {
         ((IEnemy)character).KillFromBelow(spawnForce.y);
     }
 }
示例#22
0
    public override void Awake()
    {
        base.Awake();
        neighbors = new List <HexGrid>();

        //initialize states
        stateList = new List <HexGridState>();
        stateList.Add(new HexGridState());
        stateList.Add(new TokenGridState());
        stateList.Add(new ReachGridState());
        stateList.Add(new EnemyGridState());

        state = State("default");

        //detect grid neighbors
        Vector3 point1 = this.transform.position + Vector3.up * radarHeight;
        Vector3 point2 = this.transform.position + Vector3.down * radarHeight;

        Collider[] detected = Physics.OverlapCapsule(point1, point2, radarRadius, gridLayer);
        foreach (Collider c in detected)
        {
            RaycastCollider collider = c.GetComponent <RaycastCollider>();
            if (collider != null && collider.target is HexGrid && collider.target != this)
            {
                neighbors.Add((HexGrid)collider.target);
            }
        }

        //detect token on top
        detected = Physics.OverlapSphere(this.transform.position, 0.05f, tokenLayer);
        foreach (Collider c in detected)
        {
            Token t = c.transform.GetComponent <Token>();
            token = t;
            if (t != null)
            {
                state   = State("token");
                t.place = this;
                t.transform.position = this.transform.position;
                break;
            }
        }

        state.OnEnter(this);
    }
示例#23
0
 /// <summary>
 /// When hit from the sides latch the character (unless we have a box on top of us).
 /// </summary>
 override public void DoAction(RaycastCollider collider, RaycastCharacterController controller)
 {
     if (!BoxOnTop)
     {
         if (collider.direction == RC_Direction.LEFT)
         {
             Latch(controller, RC_Direction.LEFT);
         }
         else if (collider.direction == RC_Direction.RIGHT)
         {
             Latch(controller, RC_Direction.RIGHT);
         }
     }
     else
     {
         UnLatch();
     }
 }
示例#24
0
    void Update()
    {
        if (block || EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        Debug.DrawRay(ray.origin, ray.direction * 10, Color.cyan);

        if (Physics.Raycast(ray, out hit, Mathf.Infinity, interactableLayer))
        {
            RaycastCollider target = hit.transform.GetComponent <RaycastCollider>();
            if (target != null && lastHit != target)
            {
                if (lastHit != null)
                {
                    lastHit.OnPointerExit();
                }
                target.OnPointerEnter();
                lastHit = target;
            }
        }
        else
        {
            if (lastHit != null)
            {
                lastHit.OnPointerExit();
                lastHit = null;
            }
        }

        if (lastHit != null && Input.GetMouseButtonDown(0))
        {
            lastHit.OnClick(0);
        }
        if (lastHit != null && Input.GetMouseButtonDown(1))
        {
            lastHit.OnClick(1);
        }
    }
示例#25
0
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (character.StartedClimbing)
     {
         // Swing rope
         if (character.characterInput.x > 0.0f && control.LastSwingDirection <= 0.0f)
         {
             swingForce = new Vector3(Mathf.Abs(Mathf.Cos(Mathf.Deg2Rad * myTransform.rotation.eulerAngles.z)) * character.climbing.ropeSwingForce, 0.0f, 0.0f);
             control.LastSwingDirection = 1;
             control.hasSwung           = true;
         }
         else if (character.characterInput.x < 0.0f && control.LastSwingDirection >= 0.0f)
         {
             swingForce = new Vector3(Mathf.Abs(Mathf.Cos(Mathf.Deg2Rad * myTransform.rotation.eulerAngles.z)) * character.climbing.ropeSwingForce * -1, 0.0f, 0.0f);
             control.LastSwingDirection = -1;
             control.hasSwung           = true;
         }
         // Move up and down rope
         if (!control.hasClimbed)
         {
             Vector2 climbForce = Vector2.zero;
             if (character.characterInput.y > 0.0f)
             {
                 control.hasClimbed = true;
                 climbForce.y       = character.climbing.speed * RaycastCharacterController.FrameTime;
             }
             else if (character.characterInput.y < 0.0f)
             {
                 control.hasClimbed = true;
                 climbForce.y       = -1 * character.climbing.speed * RaycastCharacterController.FrameTime;
             }
             character.transform.Translate(0.0f, Vector2.Dot(climbForce, myTransform.rotation * Vector2.up), 0.0f, Space.Self);
             float delta = myTransform.position.x - character.transform.position.x;
             character.transform.Translate(RaycastCharacterController.FrameTime * delta, 0.0f, 0.0f, Space.Self);
         }
     }
 }
示例#26
0
	/// <summary>
	/// Stand on a respawn point to activate it. You could play a particle effect of something here.
	/// </summary>
	override public void DoAction(RaycastCollider collider, RaycastCharacterController character) {
		if (collider.direction == RC_Direction.DOWN) currentRespawnPoint = this;
	}
示例#27
0
 /// <summary>
 /// This is called when a platform is hit. Override to implement platform behaviour.
 /// </summary>
 /// <param name='collider'>
 /// The collider that did the hitting.
 /// </param>
 /// <param name='character'>
 /// The character that did the hitting.
 /// </param>
 virtual public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     // Do nothing
 }
示例#28
0
    protected override void Execute(List <LogicEntity> entities)
    {
        foreach (LogicEntity e in entities)
        {
            horizontalHit = FixedVector2.NAN;
            verticallHit  = FixedVector2.NAN;

            r = e.rayCastCollision.value;
            c = e.collider.value;

            left = right = up = down = -1;

            int  direction = e.direction.value;
            long rayLength = e.move.target.x.Abs() + r.skinWidth;

            if (e.move.target.x.Abs() < r.skinWidth)
            {
                rayLength = r.skinWidth;
            }

            for (int i = 0; i < r.horizontalRayCount; i++)
            {
                FixedVector2 origin = (direction == -1) ? c.broadBounds.bottomLeft : c.broadBounds.bottomRight;
                origin += FixedVector2.UP * (r.horizontalRaySpacing * i);

                FixedVector2 hit;
                FixedVector2 end = FixedVector2.RIGHT * (rayLength * direction);
                l = new FixedLine2(origin, origin + end);

                int otherId = -1;
                if (RayCastSystem.Check(origin, end, out hit, e.id.value, c.check, out otherId))
                {
                    if (direction < 0)
                    {
                        left = otherId;
                    }

                    else
                    {
                        right = otherId;
                    }

                    long distance = (hit - origin).magnitude;
                    if (distance > minDistance)
                    {
                        distance -= minDistance;
                    }
                    else
                    {
                        distance = 0;
                    }

                    e.move.target.x = distance * direction;

                    horizontalHit = hit;
                }
            }

            direction = e.move.target.y.Sign();
            rayLength = e.move.target.y.Abs() + r.skinWidth;

            for (int i = 0; i < r.verticalRayCount; i++)
            {
                FixedVector2 origin = (direction == -1) ? c.broadBounds.bottomLeft : c.broadBounds.topLeft;
                origin.x += e.move.target.x;
                origin   += FixedVector2.RIGHT * (r.verticalRaySpacing * i);

                FixedVector2 hit;
                FixedVector2 end = FixedVector2.UP * (rayLength * direction);
                l = new FixedLine2(origin, origin + end);

                int otherId = -1;
                if (RayCastSystem.Check(origin, end, out hit, e.id.value, c.check, out otherId))
                {
                    if (direction < 0)
                    {
                        down = otherId;
                    }

                    else
                    {
                        up = otherId;
                    }

                    long distance = (hit - origin).magnitude;
                    if (distance > minDistance)
                    {
                        distance -= minDistance;
                    }
                    else
                    {
                        distance = 0;
                    }

                    e.move.target.y = distance * direction;

                    verticallHit = hit;
                }
            }

            r = null;
            c = null;

            e.ReplaceLastPosition(e.position.value);
            e.ReplacePosition(e.position.value + e.move.target);

            e.collider.value.MoveCollider(e.position.value);
            e.RemoveMove();

            RaycastCollisionInfo info = new RaycastCollisionInfo(left, right, up, down, horizontalHit, verticallHit);

            if (e.hasCollisionInfo)
            {
                info.RecordLastPreviousCollision(
                    e.collisionInfo.value.leftID,
                    e.collisionInfo.value.rightID,
                    e.collisionInfo.value.upID,
                    e.collisionInfo.value.downID
                    );
            }

            e.ReplaceCollisionInfo(info);
        }
    }
示例#29
0
	override public void DoAction(RaycastCollider collider, RaycastCharacterController character) {
		if (collider.direction == RC_Direction.DOWN) {
			character.Velocity = new Vector3(character.Velocity.x, springForce);
		}
	}
示例#30
0
 /// <summary>
 /// This is called when a platform is hit. Override to implement platform behaviour.
 /// </summary>
 /// <param name='collider'>
 /// The collider that did the hitting.
 /// </param>
 /// <param name='character'>
 /// The character that did the hitting.
 /// </param>
 virtual public void DoAction(RaycastCollider collider, RayCastColliders character)
 {
     // Do nothing
 }
示例#31
0
 void Start()
 {
     lastHit = null;
 }
示例#32
0
	/// <summary>
	/// This is called when a platform is hit. Override to implement platform behaviour.
	/// </summary>
	/// <param name='collider'>
	/// The collider that did the hitting.
	/// </param>
	/// <param name='character'>
	/// The character that did the hitting.
	/// </param>
		virtual public void DoAction(RaycastCollider collider, RayCastColliders character) {
		// Do nothing
	}
示例#33
0
	override public void DoAction(RaycastCollider collider, RaycastCharacterController character) {
		if (character.FallThroughTimer <= 0.0f && collider.direction == RC_Direction.DOWN && character.characterInput.y < 0.0f && (!requireJump ||character.characterInput.jumpButtonDown)) {
			character.FallThroughTimer = fallThroughTime;
			character.characterInput.CancelJump();
		}
	}
示例#34
0
	/// <summary>
	/// Trigger the respawn.
	/// </summary>
	override public void DoAction(RaycastCollider collider, RaycastCharacterController character) {
		character.SendMessage("Die", SendMessageOptions.DontRequireReceiver);
	}
示例#35
0
	/// <summary>
	/// This is called when a platform is hit. Override to implement platform behaviour.
	/// </summary>
	/// <param name='collider'>
	/// The collider that did the hitting.
	/// </param>
	/// <param name='character'>
	/// The character that did the hitting.
	/// </param>
	virtual public void DoAction(RaycastCollider collider, RaycastCharacterController character) {
		// Do nothing
	}
示例#36
0
 /// <summary>
 /// Trigger the respawn.
 /// </summary>
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     character.SendMessage("Die", SendMessageOptions.DontRequireReceiver);
 }