Inheritance: MonoBehaviour
    private void OnCollisionEnter2D(Collision2D collision)
    {
        waterHole.SetActive(true);
        holeText.enabled = true;
        BoatMovement boatMovement = GetComponentInParent <BoatMovement>();

        boatMovement.DropBoat();

        anvilLandSound.Play();

        if (holeNumber == 1)
        {
            boatHealth.anvil1IsOnBoat = true;
            boatHealth.GeneratePressAmount(holeNumber);
        }
        else if (holeNumber == 2)
        {
            boatHealth.anvil2IsOnBoat = true;
            boatHealth.GeneratePressAmount(holeNumber);
        }
        else
        {
            boatHealth.anvil3IsOnBoat = true;
            boatHealth.GeneratePressAmount(holeNumber);
        }
    }
Esempio n. 2
0
    private void OnCollisionEnter(Collision coll)
    {
        BoatTypes    boatColl   = coll.gameObject.GetComponent <BoatTypes>(); // gets the type of boat from the boatType enum
        BoatMovement boatScript = coll.gameObject.GetComponent <BoatMovement>();

        if (boatColl != null && boatScript != null) // only called if the boatColl is actually present
        {
            switch (boatColl.boatType)              // cycles through each element in the boat type enum
            {
            case Boats.ENEMY_1:
                boatScript.Die();     // enemies are instantly destroyed
                break;

            case Boats.MERCHANT_1:
                boatScript.Die();     // merchants are instantly destroyed
                break;

            case Boats.PLAYER:
                boatScript.TakeDamage(20);     // the player takes 20 damage
                break;

            default:
                break;
            }
        }
        Destroy(gameObject); // destroys the cannonball regardless
    }
Esempio n. 3
0
 // Use this for initialization
 void Start()
 {
     boxCollider        = GetComponent <BoxCollider>();
     boatMovementScript = GetComponent <BoatMovement>();
     InfoUI             = GameObject.FindGameObjectWithTag("UI");
     InfoUI.SetActive(false);
 }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        // variables

        // for movement
        maxSpeed           = 8f;
        moveSpeed          = 0f;
        maxReverseSpeed    = -5f;
        deccelerationSpeed = 2f;
        currentSteerSpeed  = 0f;
        rotationSpeed      = 180f;
        isInput            = false;
        controllingBoat    = false;
        boost          = 100f;
        boostUsageRate = 20f;
        isBoosting     = false;

        // for floating
        floatRotation = -90f;
        rotateRate    = 5f;

        // components
        chController = GetComponent <CharacterController>();
        theBoat      = FindObjectOfType <BoatMovement>();

        // For ui
        boostSlider.maxValue = boost;
    }
Esempio n. 5
0
 private void Start()
 {
     player     = GameObject.FindGameObjectWithTag("Player").GetComponent <BoatMovement>();
     intensity  = dirLight.intensity;
     startStorm = false;
     runOnce    = true;
 }
Esempio n. 6
0
 // Use this for initialization
 void Start()
 {
     canControlShip = false;
     moveSpeed      = 3f;
     controller     = GetComponent <CharacterController>();
     theBoat        = FindObjectOfType <BoatMovement>();
     fpsController  = GetComponent <UnityStandardAssets.Characters.FirstPerson.FirstPersonController>();
 }
Esempio n. 7
0
    void OnTriggerEnter(Collider col)
    {
        BoatMovement boat = col.gameObject.GetComponent <BoatMovement>();

        if (boat != null)
        {
            boat.Terminer();
        }
    }
Esempio n. 8
0
 /// <summary>
 /// Adds given script as a change speed invoker
 /// </summary>
 /// <param name="boat"></param>
 public static void AddChangeSpeedInvoker(BoatMovement invoker)
 {
     // add invoker to list and add all listeners to invoker
     changeSpeedInvokers.Add(invoker);
     foreach (UnityAction <BoatSpeeds> listener in changeSpeedListeners)
     {
         invoker.AddChangeSpeedListener(listener);
     }
 }
 void Start()
 {
     boatMovement    = GetComponent <BoatMovement>();
     anvil1IsOnBoat  = false;
     anvil2IsOnBoat  = false;
     anvil3IsOnBoat  = false;
     alive           = true;
     boatFace.sprite = happyFace;
 }
Esempio n. 10
0
    void UpdateListPriority()
    {
        //update the priority of each boat in the list
        for (int i = 0; i < detectedBoats.Count; i++)
        {
            //TODO sort the elements in the list in descending order of current loot * 1/distanceToBoat
            BoatMovement boatMovement = detectedBoats[i].GetComponent <BoatMovement>();
            float        priority     = boatMovement.lootAmount * (1 / (Vector3.Distance(transform.position, detectedBoats[i].transform.position))); //current loot * reciprocal of distance to NPC
        }

        //var distance = detectedBoats.Select(x => (x.transform.position - gameObject.transform.position).magnitude); //TODO read into this and learn what it does
    }
Esempio n. 11
0
 private void Awake()
 {
     m_particles = GetComponentsInChildren <ParticleSystem>();
     ToggleParticles(false);
     m_boat               = GetComponentInParent <BoatMovement>();
     m_rb                 = m_boat.GetComponent <Rigidbody>();
     m_audioSource        = GetComponent <AudioSource>();
     m_maxVol             = m_audioSource.volume;
     m_dir                = -1;
     m_audioSource.volume = 0;
     m_maxWindVol         = m_windAudio.volume;
     m_windAudio.volume   = 0;
 }
Esempio n. 12
0
    void Awake()
    {
        Rigidbody        = GetComponent <Rigidbody>();
        Movement         = GetComponent <BoatMovement>();
        Shooting         = GetComponent <BoatShooting>();
        CanvasGameObject = GetComponentInChildren <Canvas>().gameObject;

        SpawnPosition = transform.position;
        SpawnRotation = transform.rotation;

        Movement.PlayerNumber = PlayerNumber;
        Shooting.PlayerNumber = PlayerNumber;
    }
Esempio n. 13
0
    // Use this for initialization
    void Start()
    {
        //Get components
        _boatMovement = GetComponent<BoatMovement> ();
        _boatWeapons = GetComponent<BoatWeapons> ();
        _boatHealth = GetComponent<BoatHealth> ();

        //Assign controls
        _thrustButton = W_UP;
        _rotateButton = S_DOWN;
        _peanutButton = D_RIGHT;
        _torpedoButton = A_LEFT;
    }
Esempio n. 14
0
    private void Awake()
    {
        _movement = GetComponent<BoatMovement>();
        _angler = GetComponent<CannonAngler>();
        _cannonManagers = GetComponentsInChildren<CannonManager>(true);

        // Index parts for faster access
        _parts = GetComponentsInChildren<ObjectHealth>();
        for (int i = 0; i < _parts.Length; i++)
        {
            _parts[i].ID = i;
            _parts[i].Changed += OnPartChange;
        }

        _loaded = true;
    }
    private void OnTriggerEnter(Collider other)
    {
        PlaneMovement planeMovement = other.GetComponent <PlaneMovement>();
        BoatMovement  boatMovement  = other.GetComponent <BoatMovement>();

        if (planeMovement != null)
        {
            GameManager.Instance.RemoveGlobalRegionPopulation(planeMovement.RegionSpawn.m_NameRegion, GameManager.Instance.PlaneScore);
            Destroy(planeMovement.gameObject);
        }
        if (boatMovement != null)
        {
            GameManager.Instance.RemoveGlobalRegionPopulation("Asia", GameManager.Instance.PlaneScore);
            Destroy(boatMovement.gameObject);
        }
    }
Esempio n. 16
0
    void Awake()
    {
        //mBody = GetComponent<Rigidbody>();
        visibilityRadius = NetworkManager.visibilityRadius;
        //Instantiate(inventory);
        inventory      = GetComponent <Inventory>();
        ship_equipment = GetComponent <ShipEquipment>();
        //player_equipment = GetComponent<PlayerEquipment>();

        movement                   = GetComponent <BoatMovement>();
        playerEnterCollider        = GetComponentInChildren <SphereCollider>();
        playerEnterCollider.radius = NetworkManager.visibilityRadius / 2;
        //enable collider for ship when we have player character
        playerEnterCollider.enabled = false;
        mysql            = FindObjectOfType <Mysql>();
        cannonShot       = GetComponent <CannonShot>();
        cannonController = GetComponent <CannonController>();
        spawnManager     = FindObjectOfType <SpawnManager>();
    }
Esempio n. 17
0
    void OnTriggerEnter(Collider col)
    {
        BoatMovement boat = col.gameObject.GetComponent <BoatMovement>();

        if (boat != null)
        {
            if (!ramasser)
            {
                boat.RamasserCheckpoint();
                Debug.Log("vous ramasser un checkpoint");
                ramasser = true;
                gameObject.transform.parent.GetComponent <MeshRenderer>().material = used;
            }
            else
            {
                Debug.Log("vous avez déjà ramasser ce checkpoint");
            }
        }
    }
Esempio n. 18
0
    private void OnTriggerEnter(Collider other)
    {
        bool hit = false, boat = false;

        if (other.GetComponentInParent <BoatMovement>())
        {
            hit  = true;
            boat = true;
        }
        else if (other.GetComponent <PlayerMovement>())
        {
            hit = true;
        }

        if (hit == true)
        {
            BoatMovement bm = null;
            if (boat == true)
            {
                // m_player = other.GetComponentInChildren<PlayerMovement>().transform;
                bm       = other.GetComponentInParent <BoatMovement>();
                m_player = bm.transform.GetChild(3);
                PlayerDontMove(true);
                bm.m_specialDismountBoat = true;
            }
            else
            {
                m_player = other.GetComponent <PlayerMovement>().transform;
                PlayerDontMove(true);
            }
            DropBoatParts();

            //turn off this triggerbox
            GetComponent <BoxCollider>().enabled = false;
            //turnoff all other colliders
            transform.GetChild(0).gameObject.SetActive(false);

            SpecialStart();
            //at the end of the scene turn off boat
        }
    }
Esempio n. 19
0
 // Use this for initialization
 void Start()
 {
     player    = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerScript>();
     boatAlive = GameObject.FindGameObjectWithTag("Player").GetComponent <BoatMovement>();
 }