Example #1
0
    public void CoinMove(CarDirection dir)
    {
        float x = 0.0f;

        if (dir == CarDirection.Left)
        {
            x = -300.0f;
        }
        else if (dir == CarDirection.Left)
        {
            x = 300.0f;
        }
        else
        {
            x = 0.0f;
        }

        tween.enabled = true;
        tween.AddOnFinished(delegate {
            GameObject.Destroy(gameObject);
        });
        tween.from   = new Vector3(x, -100.0f, 0.0f);
        tween.to     = new Vector3(x, 100.0f, 0.0f);
        tween.method = UITweener.Method.EaseIn;
        tween.PlayForward();
    }
Example #2
0
	public void Move(CarDirection dir)
	{
		Direction = dir;
		Vector3 pos = Vector3.zero;
		if (dir == CarDirection.Left) {
			pos = new Vector3(-230, 80, 0);
		} else if (dir == CarDirection.Center) {
			pos = new Vector3(0, 100, 0);
		} else {
			pos = new Vector3(230, 80, 0);
		}

		iTween.MoveTo(gameObject, iTween.Hash("position", pos, "islocal", true, "time", 0.8f));
	}
Example #3
0
    private void Update()
    {
        #region Inputs
        if (Input.GetMouseButtonDown(0))
        {
            swipe = true;
            swipeFirstPosition = Input.mousePosition.x;
            StartCoroutine(Swiping());
        }
        if (Input.GetMouseButton(0) && swipe)
        {
            swipeFinished = false;
        }
        if (Input.GetMouseButtonUp(0))
        {
            swipe         = false;
            swipeFinished = true;
            carDirection  = CarDirection.None;
            StopCoroutine(Swiping());
            isDriftingStopped = true;
        }
        #endregion

        #region Rotations
        if (carDirection == CarDirection.Left)
        {
            movement.TurnLeft();
            driftLine.StartEmitting();
            carDriftDust.OpenDust();
        }
        else if (carDirection == CarDirection.Right)
        {
            movement.TurnRight();
            driftLine.StartEmitting();
            carDriftDust.OpenDust();
        }
        else
        {
            if (isDriftingStopped) // I check drifting status to call these operations once
            {
                driftLine.StopEmitting();
                StartCoroutine(carDriftDust.DriftDust());
                isDriftingStopped = false;
            }
        }
        #endregion

        carPowerUpControl.CheckForPowerUp(ballColliderCommon, carColliderCommon, ballPosition, ball);
    }
Example #4
0
    private void Awake()
    {
        movement          = GetComponent <CarMovement>();
        driftLine         = GetComponent <CarDriftLine>();
        carColliderCommon = GetComponent <ColliderCommon>();
        ball               = GameObject.FindGameObjectWithTag("Ball").transform;
        ballPosition       = GameObject.FindGameObjectWithTag("BallPosition").transform;
        ballColliderCommon = ball.GetComponent <ColliderCommon>();
        carDriftDust       = GetComponent <CarDriftDust>();
        animator           = GetComponent <Animator>();
        carPowerUpControl  = GetComponent <CarPowerUpControl>();

        carDirection = CarDirection.None;

        isAlive = true;
    }
Example #5
0
    public void Right()
    {
        CarDirection dir = CarDirection.Right;

        if (Direction == CarDirection.Left)
        {
            ani.SetTrigger("right");
            dir = CarDirection.Center;
        }
        else if (Direction == CarDirection.Center)
        {
            ani.SetTrigger("right");
            dir = CarDirection.Right;
        }

        _Move(dir);
    }
Example #6
0
    private void IdentifyDriftTimeAndRotation()
    {
        int direction = Random.Range(0, 2);

        if (direction == 0)
        {
            carDirection = CarDirection.Right;
        }
        else
        {
            carDirection = CarDirection.Left;
        }

        StartCoroutine(Drifting(RandomDriftingTime()));

        aIState = AIStates.Drift;
    }
Example #7
0
    public void SpawnNewCar(CarDirection carDirection)
    {
        switch (carDirection)
        {
        case CarDirection.LeftToRight:
        {
            Instantiate(CarPrefab, carSpawnPointLR, Quaternion.Euler(0f, 90f, 0f));
            break;
        }

        case CarDirection.RightToLeft:
        {
            Instantiate(CarPrefab, carSpawnPointRL, Quaternion.Euler(0f, 270f, 0f));
            break;
        }
        }
    }
Example #8
0
	public void CoinMove(CarDirection dir)
	{
		float x = 0.0f;
		if (dir == CarDirection.Left) {
			x = -300.0f;
		} else if (dir == CarDirection.Left) {
			x = 300.0f;
		} else {
			x = 0.0f;
		}

		tween.enabled = true;
		tween.AddOnFinished(delegate {
			GameObject.Destroy(gameObject);
		});
		tween.from = new Vector3(x, -100.0f, 0.0f);
		tween.to = new Vector3(x,  100.0f, 0.0f);
		tween.method = UITweener.Method.EaseIn;
		tween.PlayForward();
	}
Example #9
0
    void _Move(CarDirection dir)
    {
        Vector3 pos = Vector3.zero;

        if (dir == CarDirection.Center)
        {
            pos = new Vector3(0, -100, 0);
        }
        else if (dir == CarDirection.Left)
        {
            pos = new Vector3(-300, -100, 0);
        }
        else if (dir == CarDirection.Right)
        {
            pos = new Vector3(300, -100, 0);
        }

        Direction = dir;
        iTween.MoveTo(gameObject, iTween.Hash("position", pos, "islocal", true, "time", 0.5f));
    }
Example #10
0
    public void Move(CarDirection dir)
    {
        Direction = dir;
        Vector3 pos = Vector3.zero;

        if (dir == CarDirection.Left)
        {
            pos = new Vector3(-230, 80, 0);
        }
        else if (dir == CarDirection.Center)
        {
            pos = new Vector3(0, 100, 0);
        }
        else
        {
            pos = new Vector3(230, 80, 0);
        }

        iTween.MoveTo(gameObject, iTween.Hash("position", pos, "islocal", true, "time", 0.8f));
    }
Example #11
0
    void _Attack()
    {
        if (Enermy.State == EnermyState.Ready)
        {
            _CreateEnemy();
        }

        if (Car.Direction == Enermy.Direction)
        {
            Car.Attack();
            Enermy.PreferDie();
        }
        else
        {
            int          i   = UnityEngine.Random.Range(0, 3);
            CarDirection dir = CarDirection.Left;
            if (i == 0)
            {
                dir = CarDirection.Center;
            }
            else if (i == 1)
            {
                dir = CarDirection.Left;
            }
            else if (i == 2)
            {
                dir = CarDirection.Right;
            }

            if (dir == Car.Direction)
            {
                Enermy.Attack();
                Car.Demage();
            }

            Enermy.Move(dir);
        }
    }
Example #12
0
    public IEnumerator Swiping()
    {
        yield return(new WaitForSeconds(swipingInSeconds));

        if (swipe)
        {
            differenceBetweenSwipePositions = Input.mousePosition.x - swipeFirstPosition;

            if (differenceBetweenSwipePositions < 0)
            {
                carDirection = CarDirection.Left;
            }
            else if (differenceBetweenSwipePositions > 0)
            {
                carDirection = CarDirection.Right;
            }

            if (!swipeFinished)
            {
                StartCoroutine(Swiping());
            }
        }
    }
Example #13
0
    public void Show()
    {
        int          i   = UnityEngine.Random.Range(0, 3);
        CarDirection dir = CarDirection.Center;

        if (i == 0)
        {
            dir = CarDirection.Center;
        }
        else if (i == 1)
        {
            dir = CarDirection.Left;
        }
        else if (i == 2)
        {
            dir = CarDirection.Right;
        }

        Move(dir);

        State = EnermyState.Show;
        gameObject.SetActive(true);
    }
Example #14
0
        public Car(CarPos carPos, CarDirection carDirection, String carGraphic, Program program1, Road carRoad, SemaphoreSlim godOfRoad)
        {
            program = program1;
            road    = carRoad;
            roadGod = godOfRoad;
            speed   = randSpeed.Next(100, 500);
            carDir  = carDirection;
            switch (carDirection)
            {
            case CarDirection.FORWARD:
                switch (carPos)
                {
                case CarPos.TOP:
                    carDestination = CarPos.BOTTOM;
                    break;

                case CarPos.RIGHT:
                    carDestination = CarPos.LEFT;
                    break;

                case CarPos.BOTTOM:
                    carDestination = CarPos.TOP;
                    break;

                case CarPos.LEFT:
                    carDestination = CarPos.RIGHT;
                    break;
                }
                break;

            case CarDirection.TURN_RIGHT:
                switch (carPos)
                {
                case CarPos.TOP:
                    carDestination = CarPos.LEFT;
                    break;

                case CarPos.RIGHT:
                    carDestination = CarPos.TOP;
                    break;

                case CarPos.BOTTOM:
                    carDestination = CarPos.RIGHT;
                    break;

                case CarPos.LEFT:
                    carDestination = CarPos.BOTTOM;
                    break;
                }
                break;

            case CarDirection.TURN_LEFT:
                switch (carPos)
                {
                case CarPos.TOP:
                    carDestination = CarPos.RIGHT;
                    break;

                case CarPos.RIGHT:
                    carDestination = CarPos.BOTTOM;
                    break;

                case CarPos.BOTTOM:
                    carDestination = CarPos.LEFT;
                    break;

                case CarPos.LEFT:
                    carDestination = CarPos.TOP;
                    break;
                }
                break;
            }

            switch (carDestination)
            {
            case CarPos.TOP:
                carColor = new Terminal.Gui.Attribute(Color.BrightGreen, Color.Black);
                break;

            case CarPos.RIGHT:
                carColor = new Terminal.Gui.Attribute(Color.BrightYellow, Color.Black);
                break;

            case CarPos.BOTTOM:
                carColor = new Terminal.Gui.Attribute(Color.BrightRed, Color.Black);
                break;

            case CarPos.LEFT:
                carColor = new Terminal.Gui.Attribute(Color.BrightBlue, Color.Black);
                break;
            }
            //pozniej zalezne od kierunku
            graphic       = carGraphic;
            positionMutex = new Mutex();
            lockPosition();
            pos_X       = road.getStartPointX(carPos);
            pos_Y       = road.getStartPointY(carPos);
            posOrigin_X = pos_X;
            posOrigin_Y = pos_Y;
            unlockPosition();
            switch (carPos)
            {
            case CarPos.TOP:
                carRot = CarRotation.DOWN;
                break;

            case CarPos.RIGHT:
                carRot = CarRotation.LEFT;
                break;

            case CarPos.BOTTOM:
                carRot = CarRotation.UP;
                break;

            case CarPos.LEFT:
                carRot = CarRotation.RIGHT;
                break;
            }
        }
Example #15
0
        private void GenerateCarsProc()
        {
            int MAX_CAR_NUMBER = simRoad.getMAX_CAR_NUMBER();
            //int CURRENT_CAR_NUMBER = 0;
            int          frequency = 200;
            int          genX      = 0;
            int          genY      = 0;
            CarPos       newCarPos = CarPos.TOP;
            CarDirection newCarDir = CarDirection.FORWARD;

            while (getPrun())
            {
                //zmienic na dopoki kolejka ma symbole
                if (simRoad.getQueueLength() > 0)//CURRENT_CAR_NUMBER < MAX_CAR_NUMBER)
                {
                    //losuj carPos
                    int temp = 0;
                    lock (randLock)
                    {
                        temp = rand.Next() % 4;
                    }
                    switch (temp)
                    {
                    case 0:
                        newCarPos = CarPos.TOP;
                        break;

                    case 1:
                        newCarPos = CarPos.RIGHT;
                        break;

                    case 2:
                        newCarPos = CarPos.BOTTOM;
                        break;

                    case 3:
                        newCarPos = CarPos.LEFT;
                        break;
                    }
                    genX = simRoad.getStartPointX(newCarPos);
                    genY = simRoad.getStartPointY(newCarPos);
                    simRoad.GetRoadMutex(genX, genY).WaitOne();
                    // :::::::::::
                    if (simRoad.checkSpace(genX, genY))
                    {
                        lock (randLock)
                        {
                            temp = rand.Next() % 3;
                        }
                        switch (temp)
                        {
                        case 0:
                            newCarDir = CarDirection.FORWARD;
                            break;

                        case 1:
                            newCarDir = CarDirection.TURN_LEFT;
                            break;

                        case 2:
                            newCarDir = CarDirection.TURN_RIGHT;
                            break;
                        }

                        Car    newCar       = new Car(newCarPos, newCarDir, simRoad.popCharacter(), this, simRoad, godOfRoad);
                        Thread newCarThread = new Thread(new ThreadStart(newCar.ThreadProc));
                        //newCarThread.Name= String.Format("{0}", i);
                        newCarThread.Start();
                        newCar.setThread(newCarThread);
                        cars.Add(newCar);
                        //CURRENT_CAR_NUMBER++;
                    }
                    simRoad.GetRoadMutex(genX, genY).ReleaseMutex();
                }
                Thread.Sleep(frequency);
            }
        }
Example #16
0
	void _Move(CarDirection dir)
	{
		Vector3 pos = Vector3.zero;
		if (dir == CarDirection.Center) {
			pos = new Vector3(0, -100, 0);
		} else if (dir == CarDirection.Left) {
			pos = new Vector3(-300, -100, 0);
		} else if (dir == CarDirection.Right) {
			pos = new Vector3(300, -100, 0);
		}

		Direction = dir;
		iTween.MoveTo(gameObject, iTween.Hash("position", pos, "islocal", true, "time", 0.5f));
	}