Esempio n. 1
0
 public Car(Drivable drivable)
 {
     _drivable           = drivable;
     this.EngineSize     = 1600;
     this.NumberOfWheels = 4;
     _drivable.Drive("car");
 }
    // This spawns all clones **at the same time** but separated by the distance vector
    public void CloneSpawnEnemyWavesSeparatedByDistance(MonoBehaviour gameObject, int cloneCount, Vector2 distance)
    {
        for (int i = 0; i < cloneCount; i++)
        {
            // Create a clone of the ship
            Drivable shipInterface = MonoBehaviour.Instantiate(ship).GetComponent <Drivable>();

            // Set the ship and execute
            shipInterface.Initialize(position: position + i * distance, rotation: rotation);
            gameObject.StartCoroutine(ExecuteFlightInstructions(shipInterface));
        }
    }
Esempio n. 3
0
        public void KartFinishedRace(Drivable kart)
        {
            int kartIndex = playerCars.FindIndex(drivable => drivable == kart) + 1;

            _rankingList.Add(kartIndex);
            Debug.Log("Kart finished! " + kartIndex);

            // All cars finished
            if (_rankingList.Count == playerCars.Count)
            {
                MiniGameFinished(new [] { _rankingList[0] }, new int[] {}, new int[] {}, new int[] {});
            }
        }
Esempio n. 4
0
        private void Start()
        {
            _navAgent = GetComponent <NavMeshAgent>();
            // disable automatic position updates so that we move the agent via our drive system instead of the agnet
            // setting its position itself
            _navAgent.updatePosition = false;
            _navAgent.updateRotation = false;

            _drivable = GetComponent <Drivable>();

            _currentWaypointIndex = -1;
            NextWaypoint();
        }
    public IEnumerator CloneSpawnEnemyWavesSeparatedByTimeHelper(MonoBehaviour gameObject, int cloneCount, float delay)
    {
        for (int i = 0; i < cloneCount; i++)
        {
            // Create a clone of the ship
            Drivable shipInterface = MonoBehaviour.Instantiate(ship).GetComponent <Drivable>();

            // Set the ship and execute
            shipInterface.Initialize(position: position, rotation: rotation);
            gameObject.StartCoroutine(ExecuteFlightInstructions(shipInterface));

            // Delay between each enemy
            yield return(new WaitForSeconds(delay));
        }
        yield break;
    }
    private IEnumerator ExecuteFlightInstructions(Drivable shipInterface)
    {
        // Check if ship is null
        if (shipInterface == null)
        {
            Debug.LogError("FlightPlan Error: ship is null.");
            yield break;
        }

        // Execute the flight plan!
        Debug.Log("FlightPlan Execute function start!!");
        foreach (FlightInstruction i in instructions)
        {
            if (!shipInterface.IsDrivable())
            {
                break;
            }
            Debug.Log("FlightPlan Execute function foreach");
            switch (i.action)
            {
            case FlightInstruction.Action.Wait:
                yield return(new WaitForSeconds(i.floatParam));

                break;

            case FlightInstruction.Action.SetVelocity:
                shipInterface.SetVelocity(velocity: i.floatParam);
                break;

            case FlightInstruction.Action.Shoot:
                shipInterface.Shoot(continuous: i.boolParam, fireRate: i.floatParam);
                break;

            case FlightInstruction.Action.Rotate:
                shipInterface.SetAngularVelocity(angularVelocity: i.floatParam);
                break;

            case FlightInstruction.Action.AccelerateForward:
                shipInterface.AccelerateForward(timeInSeconds: i.floatParam);
                break;
            }
        }
        yield break;
    }