private void ObstacleExplosion()
    {
        Collider[] objectsInExpRadius = Physics.OverlapSphere(transform.position, expRadius);
        foreach (Collider col in objectsInExpRadius)
        {
            if (col.gameObject.tag == "Player")
            {
                ShipControls shipSC = col.GetComponent <ShipControls>();

                if (shipSC != null)
                {
                    shipSC.DeathFX();
                }

                //////////////////////////////////////

                Rigidbody shipRB = col.GetComponent <Rigidbody>();

                if (shipRB != null)
                {
                    shipRB.AddExplosionForce(explosionForce, transform.position, expRadius);
                }
            }
            else
            {
                Obstacle colObs = col.GetComponent <Obstacle>();

                if (colObs != null)
                {
                    colObs.ObstacleDestruct();
                }
            }
        }
    }
Exemple #2
0
        void Start()
        {
            // Make the rigid body not change rotation
            if (GetComponent <Rigidbody>())
            {
                GetComponent <Rigidbody>().freezeRotation = true;
            }
            originalRotation = transform.localRotation;

            Ship = GetComponent <ShipControls>();
        }
Exemple #3
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        ShipControls ship = collider.gameObject.GetComponent <ShipControls>();

        if (ship != null)
        {
            ship.deactivateShip();
            GameState.Instance.LastCheckPointNumber = 0;
            CameraFade.StartAlphaFade(Color.black, false, 1.25f, 0.4f, () => { GameState.Instance.loadNextLevel(); });
        }
    }
	// Use this for initialization
	void Start () {
		Boat = GameObject.Find("Water_Powerboat");
		if (Boat) {
			originalPosition = Boat.transform.position;
			originalRotation = Boat.transform.rotation;
			controls = Boat.GetComponent<ShipControls>();
			if (!controls) Debug.Log("BoatWatercourseCollisions: No ShipControls Reference. This is a bug.");
		}
		else {
			Debug.Log("BoatWatercourseCollisions: No Boat Reference. This is a bug.");
		}
	}
    // Start is called before the first frame update
    void Start()
    {
        chromaticAberration = ScriptableObject.CreateInstance <ChromaticAberration>();
        chromaticAberration.enabled.Override(true);
        chromaticAberration.intensity.Override(0f);

        // PostProcessVolume postProcessVolume = GetComponent<PostProcessVolume>();
        // var postProcessProfile = postProcessVolume.profile;
        // postProcessProfile.AddSettings(chromaticAberration);

        ppv = PostProcessManager.instance.QuickVolume(gameObject.layer, 0f, chromaticAberration);

        shipControl = referenceShip.GetComponent <ShipControls>();
    }
 // Use this for initialization
 void Start()
 {
     Boat = GameObject.Find("Water_Powerboat");
     if (Boat)
     {
         originalPosition = Boat.transform.position;
         originalRotation = Boat.transform.rotation;
         controls         = Boat.GetComponent <ShipControls>();
         if (!controls)
         {
             Debug.Log("BoatWatercourseCollisions: No ShipControls Reference. This is a bug.");
         }
     }
     else
     {
         Debug.Log("BoatWatercourseCollisions: No Boat Reference. This is a bug.");
     }
 }
Exemple #7
0
    void RandomHoleGenerator()
    {
        if (Random.value < 0.1)
        {
            BoxCollider2D shipCollider = transform.parent.gameObject.GetComponent <BoxCollider2D> ();
            float         xPos         = transform.position.x;
            float         yPos         = transform.position.y;
            float         randomX      = Random.Range(-xDim, xDim);
            float         randomY      = Random.Range(-yDim, yDim);

            /*float angle = Mathf.Deg2Rad * transform.eulerAngles.z;
             * float xFinal = randomX * Mathf.Cos (angle) - randomY * Mathf.Sin (angle);
             * float yFinal = randomY * Mathf.Cos (angle) + randomX * Mathf.Sin (angle);
             *
             * CreateHole(xFinal + xPos, yFinal + yPos);*/
            Vector2 v2 = ShipControls.RotatePointAroundOrigin(transform.position, new Vector2(randomX, randomY), transform.eulerAngles.z);
            CreateHole(v2.x, v2.y);
        }
    }
 // Update is called once per frame
 void Update()
 {
     shipControls = gameManager.prefabManager.currentPrefab.GetComponent <ShipControls>();
     tankControls = gameManager.prefabManager.currentPrefab.GetComponent <SimpleTankController>();
     //if (currentDialog == null) showDialog = false;
     if (Input.GetKeyDown(KeyCode.Space) && showDialog)
     {
         // nextDialog = currentDialog.nextDialog;
         previousDialog = currentDialog;
         if (currentDialog.keepParentSize)
         {
             parentRect = new Rect(currentDialog.position.x, currentDialog.position.y, currentDialog.size.x, currentDialog.size.y);
         }
         currentDialog = nextDialog;
         if (nextDialog == null || currentDialog == null)
         {
             showDialog = false;
         }
     }
 }
Exemple #9
0
	public LuaFunction boundMessageFunction; //Reference to bound Lua function set within Lua
	
	// Constructor
	public LuaAPI() {
		// create new instance of Lua
		lua = new Lua();
		
		// Initialize array.
		movementQueue = new Queue();
		
		// Get the UnityEngine reference
		lua.DoString("UnityEngine = luanet.UnityEngine");
		
		// get the boat and its controls
		boat = GameObject.FindGameObjectWithTag("TheBoat");
		shipControls = boat.GetComponent<ShipControls>();
		
		//Tell Lua about the LuaBinding object to allow Lua to call C# functions
		lua["luabinding"] = this;
		
		//Run the code contained within the file
		lua.DoFile(Application.streamingAssetsPath + "/" + drivers);
	}
Exemple #10
0
    public LuaFunction boundMessageFunction;     //Reference to bound Lua function set within Lua

    // Constructor
    public LuaAPI()
    {
        // create new instance of Lua
        lua = new Lua();

        // Initialize array.
        movementQueue = new Queue();

        // Get the UnityEngine reference
        lua.DoString("UnityEngine = luanet.UnityEngine");

        // get the boat and its controls
        boat         = GameObject.FindGameObjectWithTag("TheBoat");
        shipControls = boat.GetComponent <ShipControls>();

        //Tell Lua about the LuaBinding object to allow Lua to call C# functions
        lua["luabinding"] = this;

        //Run the code contained within the file
        lua.DoFile(Application.streamingAssetsPath + "/" + drivers);
    }
Exemple #11
0
    // Use this for initialization
    private void Start()
    {
        _shipControls = Ship.GetComponent <ShipControls>();

        if (isLocalPlayer)
        {
            foreach (var cam in Camera.allCameras)
            {
                cam.tag     = "Untagged";
                cam.enabled = false;
            }

            TpsCamera.tag = "MainCamera";
            TpsCamera.GetComponent <Camera>().enabled = true;

            CustomNetworkManager.Instance.OnStartLocalPlayer(gameObject);
        }
        else
        {
            TpsCamera.GetComponent <Camera>().enabled = false;
        }
    }
Exemple #12
0
    void Start()
    {
        //Initializing the power bar
        Image fill = GameObject.Find("Image_PowerBarForeground").GetComponent <Image>();

        powerBar = new LaunchPower(ref fill);
        powerBar.UpdatePower(finalPower, fullWidth);

        //Initializing the launc arc
        Image arc = GameObject.Find("Image_LaunchArc").GetComponent <Image>();

        arcArrow = new LaunchArc(ref arc);
        arcArrow.SetCamera(ref cam);

        //Initializing the launch arrow
        Image arrow = GameObject.Find("Image_LaunchArrow").GetComponent <Image>();

        arcArrow.LaunchArrow(ref arrow);

        //Initializing ShipControl
        sqMag   = Mathf.Infinity;
        control = new ShipControls();
    }
Exemple #13
0
    // https://forum.unity.com/threads/how-do-i-calculate-accurately-time-passed-in-seconds-for-c.191434/

    /*
     *  private void Update()
     *  {
     *          _timer += Time.deltaTime;
     *          if (_timer >= _duration)
     *          {
     *                  _timer = 0f;
     *                  // Do Stuff here
     *          }
     * }
     */



    // perhaps this should be in AstronautControls.cs, or Astronaut.cs, instead, probably just Austronaut.cs, nice and general.

    public void FootstepsAudio()
    {
        // the player loads later, so ship controls are not available at initialization, this is an inconvenience having something load later, perhaps we should load right away these type of things, and the only things we don't load are the planets and universe generation type stuff

        if (shipControls == null)
        {
            shipControls = FindObjectOfType <ShipControls>();
        }



        // check that if enough time passed, play the sound of footsteps


        timer += Time.deltaTime;

        if (timer >= timeDelay)
        {
            timer      = 0f;
            timePassed = true;
        }

        else
        {
            timePassed = false;
        }


        if ((Input.GetKey(KeyCode.W)) &&
            shipControls.empty == true &&             // check for empty ship, since astronaut will only walk when not in the (empty) ship
            timePassed)                // we only want to play one sound per whatever
        {
            footstepsAudioSource.GetComponent <AudioSource>().Play();
            // Debug.Log("test");
        }
    }
 private void Start()
 {
     AudioSource  = GetComponent <AudioSource>();
     ShipControls = GetComponentInParent <ShipControls>();
 }
Exemple #15
0
 private void Start()
 {
     defaultFov = Camera.main.fieldOfView;
     Ship       = GameObject.FindGameObjectWithTag("Player").GetComponent <ShipControls>();
 }
Exemple #16
0
 // Use this for initialization
 private void Start()
 {
     _ship  = GetComponent <ShipControls>();
     _agent = GetComponent <NavMeshAgent>();
 }
 // Use this for initialization
 void Start()
 {
     // controlType = new ConsoleType();
     if (this.tag == "Navigation")
     {
         shipControl = GetComponent<ShipControls>();
     }
 }
Exemple #18
0
    // Update is called once per frame
    void Update()
    {
        ShipControls         shipControls   = prefabManager.currentPrefab.GetComponent <ShipControls>();
        SimpleTankController tankController = prefabManager.currentPrefab.GetComponent <SimpleTankController>();

        if (shipControls != null)
        {
            projectileData = shipControls.shipWeapon.projectile.GetComponent <Projectile>();
        }
        if (tankController != null)
        {
            projectileData = tankController.groundWeapon.projectile.GetComponent <Projectile>();
        }

        /*if (Input.GetKeyDown (KeyCode.Q)) {
         *  shoot = !shoot;
         *  GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target = null;
         * }*/
        //if (GameObject.Find("UIManager").GetComponent<SelectionUI>().target != null)
        //{
        //float _angle = myGetAngle (frontMount.position, GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform.position);

        //projectileOrigin.LookAt (GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform);

        //if (GameObject.Find("UIManager").GetComponent<SelectionUI>().target){
        // facingFront = IsFacingObject(frontMount, GameObject.Find("UIManager").GetComponent<SelectionUI>().target.transform);
        // facingRear = IsFacingObject(rearMount, GameObject.Find("UIManager").GetComponent<SelectionUI>().target.transform);

        //bool facingLeft = IsFacingObject (leftMount, GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform);
        //bool facingRight = IsFacingObject (rightMount, GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform);
        //shoot = false;

        // if (facingFront)
        // {
        // projectileOrigin = frontMount;
        // // projectileOrigin.LookAt (GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform);
        // direction = projectileOrigin.forward;
        //facingFront = false;
        //shoot = true;
        //     }
        //      if (facingRear)
        //     {
        //         projectileOrigin = rearMount;
        //      projectileOrigin.LookAt (GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform);
        //         direction = projectileOrigin.forward;
        //      facingRear = false;
        //         //shoot = true;
        //     }
        // } else {
        projectileOrigin = frontMount;
        //projectileOrigin.rotation = new Quaternion(0, 0, 0, 0);
        //facingFront = false;
        //facingRear = false;
        direction = projectileOrigin.forward;
        //}
        //if (GameObject.Find ("GameManager").GetComponent<GameManager> ().playerLocation == GameDataTypes.locationType.Air) direction = Vector3.down;

        //}
        if (Input.GetKeyDown(KeyCode.Period))
        {
            //if (GameObject.Find("UIManager").GetComponent<SelectionUI>().target != null)
            //{
            //Transform temp = projectileOrigin;
            //temp.LookAt (GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform);
            GameObject bullet = Instantiate(weapon.projectile.gameObject, projectileOrigin.position + direction, projectileOrigin.rotation) as GameObject;

            //bullet.GetComponent<Rigidbody> ().velocity = transform.TransformDirection (GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform.position) * projectileData.speed;

            //projectileOrigin.LookAt (GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform);
            bullet.GetComponent <Rigidbody>().AddForce(projectileOrigin.forward * projectileData.speed);
            //facingRear = false;
            //facingFront = false;
            //projectileOrigin.transform.rotation = Quaternion.identity;
            Destroy(bullet.gameObject, 25f);
            //}

            /* else {
             *              projectileOrigin.LookAt (Vector3.up);
             *              bullet.GetComponent<Rigidbody> ().AddForce (transform.forward * projectileData.speed);
             *          }*/
        }
    }
Exemple #19
0
 void Start()
 {
     ship = GetComponent <ShipControls> ();
 }
Exemple #20
0
 private void GetReferenceToPlayerDamage()
 {
     playerShip   = GameObject.Find("PlayerShip");
     shipControls = playerShip.GetComponent <ShipControls>();
 }
    public void _SpawnPlayer()
    {
        //spawnManager.refreshSpawnPoints();
        spawnIndex = spawnManager.FindSpawnByName(spawnManager.spawnName);

        // Debug.Log("called _SpawnPlayer() method");
        mainCamera  = GameObject.Find("MainCamera").GetComponent <Camera> ();
        mapCamera   = GameObject.Find("MapCamera").GetComponent <Camera> ();
        selectionUI = GameObject.Find("UIManager").GetComponent <SelectionUI> ();
        GameObject[] find = GameObject.FindGameObjectsWithTag("Player");
        foreach (GameObject tmp in find)
        {
            if (tmp)
            {
                Destroy(tmp);
            }
        }
        selectionUI.FindSelectionObjects();
        //SpawnPoints = GameObject.FindGameObjectsWithTag ("SpawnPoint");

        // if (isLanding)
        // {

        spawnIndex = spawnManager.FindSpawnByName(spawnManager.spawnName);
        //spawnName = "none";

        //camOffset = mainCamOffset;
        if (spawnIndex != -1)
        {
            player = GameObject.FindWithTag("Player");
            if (playerLocation == locationType.Space)
            {
                //     //Vector3 spawn = new Vector3()

                player = Instantiate(prefabManager.spacePrefab, spawnManager.SpawnPoints[spawnIndex].transform.position - (hoverPlayer * 2), spawnManager.SpawnPoints[spawnIndex].transform.rotation);
                //currentPrefab = Instantiate(spacePrefab, SpawnPoints[spawnIndex].transform.position, SpawnPoints[spawnIndex].transform.rotation);
                shipControls = player.GetComponent <ShipControls>();
                //characterManager.characterData.shipControls = shipControls;
                shipControls.hoverHeight = hoverHeight;
            }

            if (playerLocation == locationType.Air)
            {
                player       = Instantiate(prefabManager.spacePrefab, spawnManager.SpawnPoints[spawnIndex].transform.position - hoverPlayer, spawnManager.SpawnPoints[spawnIndex].transform.rotation);
                shipControls = player.GetComponent <ShipControls>();
                //characterManager.characterData.shipControls = shipControls;
                shipControls.hoverHeight = airHoverHeight;
                //GameObject.Find(spawnName).SetActive(true);
            }

            if (playerLocation.Equals(locationType.Ground))
            {
                landPlayerShip();
            }

            if (playerLocation == locationType.Building)
            {
                player = Instantiate(prefabManager.groundPrefab, spawnManager.SpawnPoints[spawnIndex].transform.position, spawnManager.SpawnPoints[spawnIndex].transform.rotation);
                //camOffset = buildingCamOffset;
                follow.offset_move = new Vector3(0, _buildingOffset, 0);
            }

            if (playerLocation != locationType.Building)
            {
            }
            //Debug.Log("player prefab -> " + player);

            prefabManager.currentPrefab = player;
            follow.target    = player.transform;
            mapFollow.target = player.transform;

            mainCamera.transform.position = player.transform.position + mainOffset;
            mapCamera.transform.position  = player.transform.position + mapOffset;
        }
        else
        {
        }
    }
Exemple #22
0
 private void Start()
 {
     spaceflight  = FindObjectOfType <Spaceflight>();
     shipControls = FindObjectOfType <ShipControls>();
 }
Exemple #23
0
 private void Start()
 {
     ShipControls = transform.GetComponentInParent <ShipControls>();
 }
Exemple #24
0
    void Update()
    {
        //turning the ship
        if (leftClick == 1)
        {
            control.Turn();
            //arcArrow.Turn ();
        }
        if (leftClick == 2)
        {
            arcArrow.launchArrow.transform.position = finalCoor;
        }

        /////////////////////////////////////For rotating the ship////////////////////////////////////////

        if (Input.GetMouseButtonDown(0) && leftClick == 0)
        {
            Vector2      mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);
            RaycastHit2D hitInfo       = Physics2D.Raycast(mousePosition, Vector2.zero);

            if (hitInfo.collider != null)
            {
                Debug.Log("hit");

                //set the gameobject to the ship if it's a hit
                string name = hitInfo.collider.gameObject.name;
                control = GameObject.Find(name).GetComponent <ShipControls>();
                control.SelectedShip(hitInfo.collider.gameObject);
                phys      = GameObject.Find(name).GetComponent <ShipPhysics> ();
                rigidbody = GameObject.Find(name).GetComponent <Rigidbody2D>();
                phys.SetRigid(rigidbody);
                phys.SetCurrent(hitInfo.collider.gameObject);

                leftClick++;
            }
            else
            {
                Debug.Log("No hit");
            }
        } //if bracket

        ///////////////////////////////////For Selecting the direction/////////////////////////////////////

        else if (Input.GetMouseButtonDown(0) && leftClick == 1)
        {
            Debug.Log("LeftClick1");
            leftClick++;

            //Gets the position of ship and mouse
            Vector3 shipPos  = control.GetShipPosition();
            Vector2 mousePos = cam.ScreenToWorldPoint(Input.mousePosition);

            //Move launch arc to clicked ship
            //arcArrow.ChangeArcPos(shipPos);
            //CalculateOffset (shipPos, mousePos);

            //math for launch arc
            float theta     = ConeDirection(mousePos, shipPos);
            float coneStart = theta - coneWidth / 2;
            float coneEnd   = theta + coneWidth / 2;

            tempDirection = theta;
            float spacing = Mathf.PI / 180;

            //begin moving launch arrow
            dirThread = new Thread(() => startDirectionCounter(spacing, coneStart, coneEnd, shipPos));
            dirThread.Start();
        }

        ////////////////////////////////////For selection power///////////////////////////
        else if (Input.GetMouseButtonDown(0) && leftClick == 2)
        {
            dirThread.Abort();
            leftClick++;
            powerInc = true;
        }

        //On the last click, we get the final power and move the ship
        else if (Input.GetMouseButtonDown(0) && leftClick == 3)
        {
            leftClick = 0;
            Debug.Log("Power:" + finalPower.ToString());
            Debug.Log("Angle:" + tempDirection.ToString());
            powerInc = false;
            powerDec = false;
            click    = true;

            moveShip(50);


            finalPower = 0;
        }

        if (powerInc)
        {
            finalPower += Time.deltaTime * barSpeed;

            //stops the power bar from going past its max length
            finalPower = Mathf.Clamp(finalPower, 0, fullWidth);

            //start decreasing power when the power reaches the maximum
            if (finalPower == fullWidth)
            {
                powerInc = false;
                powerDec = true;
            }
            powerBar.UpdatePower(finalPower, fullWidth);

            //set the width of the GUI Texture equal to that power value
            //GUITexture bar = GameObject.Find("powerBar").GetComponent<GUITexture>();
        }

        if (powerDec)
        {
            finalPower -= Time.deltaTime * barSpeed;

            //stops the power bar from goin past 0
            finalPower = Mathf.Clamp(finalPower, 0, fullWidth);

            //starts increasing power when the power reaches 0
            if (finalPower == 0)
            {
                powerInc = true;
                powerDec = false;
            }
            powerBar.UpdatePower(finalPower, fullWidth);
        }


        ////////////////////////////////////For right clicking/////////////////////////////

        if (Input.GetMouseButtonDown(1) && leftClick != 0)
        {
            leftClick--;
            powerInc   = false;
            powerDec   = false;
            finalPower = 0;
        }

        this.stopShip();
    }//update bracket
Exemple #25
0
 // Use this for initialization
 void Start()
 {
     turretTarget = transform.position;
     parentShip = GetComponentInParent<ShipControls>();
     canShoot = true;
 }