예제 #1
0
 public static void WorkHard(this Bulldozer bulldozer)
 {
     while (!bulldozer.IsServiceCheckNeeded())
     {
         bulldozer.DoSomeWork();
     }
 }
예제 #2
0
        public static string WorkHard(this Bulldozer bulldozer, int times)
        {
            while (!bulldozer.IsServiceCheckNeeded() && times > 0)
            {
                bulldozer.DoSomeWork();
                times--;
            }

            return("Work completed");
        }
예제 #3
0
        static void Main(string[] args)
        {
            kinect = new Kinect();
            kinect.KinectEventTriggered += c_KinectEventTriggered;
            kinect.KinectConnect();
            vehicle = new Bulldozer(connectionString);
            vehicle.StablishConnection();

            while (true)
            {
                stringGestureDetected(kinect.getGestureName());
            }
        }
예제 #4
0
    void OnCollisionEnter2D(Collision2D hit)
    {
        if (hit.gameObject.tag != "Player")
        {
            if (hit.collider.isTrigger == false)
            {
                //Debug.Log ("We hit " + other.name + " and did Test damage.");
                if(transform.gameObject.tag != "Player"){
                    if (hit.collider.tag == "Enemy")
                    {
                        soldier = hit.collider.gameObject.GetComponent<Soldier>();
                        mib = hit.collider.gameObject.GetComponent<MIB>();
                        dozer = hit.collider.gameObject.GetComponent<Bulldozer>();

                        if(soldier != null)
                        {
                            Debug.Log("hit");
                            soldier.DecreaseHealth(Damage);
                        }

                        if(mib != null)
                        {
                            Debug.Log("hit");
                            mib.DecreaseHealth(Damage);
                        }

                        if(dozer != null)
                        {
                            Debug.Log("hit");
                            dozer.DecreaseHealth(Damage);
                        }

                    }
                }

            }
        }

        /*
        else if (other.tag != "Player")
        {
            Destroy (gameObject);
            Debug.Log ("You were hit");
            playerGameObj = GameObject.Find("Player");
            player = playerGameObj.GetComponent<Player>();
            player.DecreaseHealth(Damage);
        }
        */
    }
예제 #5
0
    void HorizontalCollisions(ref Vector3 velocity)
    {
        float directionX = collisions.faceDir;
        float rayLength = Mathf.Abs (velocity.x) + skinWidth;

        if (Mathf.Abs(velocity.x) < skinWidth) {
            rayLength = 2*skinWidth;
        }

        for (int i = 0; i < horizontalRayCount; i ++) {
            Vector2 rayOrigin = (directionX == -1)?raycastOrigins.bottomLeft:raycastOrigins.bottomRight;
            rayOrigin += Vector2.up * (horizontalRaySpacing * i);
            RaycastHit2D hit = Physics2D.Raycast(rayOrigin, Vector2.right * directionX, rayLength, collisionMask);

            Debug.DrawRay(rayOrigin, Vector2.right * directionX * rayLength,Color.red);

            if (hit && hit.collider.isTrigger == false) {

                if(hit.collider.tag == "Enemy")
                {
                    dozer = hit.collider.gameObject.GetComponent<Bulldozer> ();

                    if(dozer != null)
                    {
                        player.DecreaseHealth(5);
                    }

                    player.DecreaseHealth(1);
                }

                if(hit.collider.tag == "Trap")
                {
                    player.DecreaseHealth(3);
                }

                if (hit.distance == 0) {
                    continue;
                }

                float slopeAngle = Vector2.Angle(hit.normal, Vector2.up);

                if (i == 0 && slopeAngle <= maxClimbAngle) {
                    if (collisions.descendingSlope) {
                        collisions.descendingSlope = false;
                        velocity = collisions.velocityOld;
                    }
                    float distanceToSlopeStart = 0;
                    if (slopeAngle != collisions.slopeAngleOld) {
                        distanceToSlopeStart = hit.distance-skinWidth;
                        velocity.x -= distanceToSlopeStart * directionX;
                    }
                    ClimbSlope(ref velocity, slopeAngle);
                    velocity.x += distanceToSlopeStart * directionX;
                }

                if (!collisions.climbingSlope || slopeAngle > maxClimbAngle) {
                    velocity.x = (hit.distance - skinWidth) * directionX;
                    rayLength = hit.distance;

                    if (collisions.climbingSlope) {
                        velocity.y = Mathf.Tan(collisions.slopeAngle * Mathf.Deg2Rad) * Mathf.Abs(velocity.x);
                    }

                    collisions.left = directionX == -1;
                    collisions.right = directionX == 1;
                }
            }
        }
    }