예제 #1
0
    // Update is called once per frame
    void Update()
    {
        Vector2 position = transform.position;

        switch (sms)
        {
        case SwarmMovementState.Neutral:
            //Trigger patrolling Animation
            if (Random.Range(0, 1000) < 30 || !((position.x >= (startLocation.x - patrolDistance)) && (position.x <= (startLocation.x + patrolDistance))))
            {
                transform.Rotate(0, 180, 0);
                positionChangeModifier = positionChangeModifier * (-1);
            }
            transform.position = new Vector3(transform.position.x + (0.03f * positionChangeModifier), transform.position.y, transform.position.z);
            break;

        case SwarmMovementState.Attacking:
            //Trigger faster fly Animation
            transform.position = new Vector3(transform.position.x + (0.08f * positionChangeModifier), transform.position.y, transform.position.z);
            break;

        default:
            sms = SwarmMovementState.Neutral;
            //Trigger patrolling Animation
            break;
        }
    }
예제 #2
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     Debug.Log(collision.name + " left the swarm");
     sms = SwarmMovementState.Neutral;
 }
예제 #3
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     Debug.Log(collision.name + " entered the Swarm");
     sms = SwarmMovementState.Attacking;
 }
예제 #4
0
 // Start is called before the first frame update
 void Start()
 {
     sms           = SwarmMovementState.Neutral;
     startLocation = transform.position;
 }