Example #1
0
 protected void Awake()
 {
     if (!_rocket)
     {
         _rocket = FindObjectOfType <RocketController>();
     }
 }
Example #2
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Example #3
0
 // Use this for initialization
 void Start()
 {
     audioSource      = GetComponent <AudioSource>();
     explodeEmitter   = explodeEffect.emission;
     rocketController = GetComponent <RocketController>();
     camShake         = FindObjectOfType <CameraShake>();
 }
Example #4
0
    public void LaunchRocket(Whose atWhose, Position targetPosition)
    {
        //		gav4.LogEvent (CATEGORY, "LaunchRocket", atWhose.ToString (), 0);
        RocketController rocketController = GetGridController(atWhose).MakeRocket();
        Vector3          localTargetPos   = targetPosition.AsGridLocalPosition(Marker.Aim);

        PosRot start = new PosRot(rocketController.transform);

        Transform targetGridTransform = GetGridController(atWhose).transform;
        Vector3   pos = targetGridTransform.position + (targetGridTransform.rotation * localTargetPos);

        pos += targetGridTransform.right * .5f + targetGridTransform.up * .5f;
        PosRot end = new PosRot(pos, targetGridTransform.rotation);

        firing++;
        rocketFlightTime = Mathf.Max(1f, .95f * rocketFlightTime);
        rocketController.Launch(atWhose, targetPosition, start, end, rocketFlightTime, delegate {
            firing--;
        });
        rocketsLaunched++;
        if (atWhose == Whose.Ours && rocketsLaunched < 7)
        {
            float duration = .7f * rocketFlightTime;
            float delay    = rocketFlightTime - duration;
            centerPanelController.IssueWarning(delay, duration);
        }
    }
Example #5
0
 public override void InitializeAgent()
 {
     zPos             = rocketObject.transform.position.z;
     rocketController = rocketObject.GetComponent <RocketController>();
     rocketProps      = rocketObject.GetComponent <RocketProps>();
     rb = rocketObject.GetComponent <Rigidbody>();
 }
Example #6
0
    /// <summary>
    /// Функция, описывающая процесс инициализации объекта
    /// </summary>
    /// <param name="_createParameter">Параметры создания</param>
    public new RocketController InstantiateObject(PoolObjectParameters _createParameter)
    {
        //Создаем переменную под контроллер объекта
        RocketController rocketController = null;

        //Если пул выключенных объектов пуст
        if (_poolOfDisabled.Count == 0)
        {
            //Создаем новую пулю
            GameObject newItem = Instantiate(PoolObjectPrefab, transform);
            rocketController = newItem.GetComponent <RocketController>();

            //Добавляем созданный объект в пул активных элементов
            _poolOfEnabled.Add(rocketController);

            //Подписываемся на событие отключение только что созданного объекта
            rocketController.ObjectDisabledEvent.AddListener(OnDisabledObj);
        }
        //Если в пуле выключенных объектов есть элементы
        else
        {
            //Переносим выключенный объект из пула неактивных элементов в пул активных
            _poolOfEnabled.Add(_poolOfDisabled[_poolOfDisabled.Count - 1]);
            _poolOfDisabled.RemoveAt(_poolOfDisabled.Count - 1);
            rocketController = (RocketController)_poolOfEnabled[_poolOfEnabled.Count - 1];
        }
        //Включить объект
        _poolOfEnabled[_poolOfEnabled.Count - 1].Enable(_createParameter);

        return(rocketController);
    }
Example #7
0
    public void Shoot()
    {
        // Raycast method to determine the object hit. Droids lose health and rockets
        // get destroyed.
        muzzleFlash1.Play();
        muzzleFlash2.Play();
        gunSound.Play();
        RaycastHit hit;

        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit))
        {
            DroidController  droid  = hit.transform.GetComponent <DroidController>();
            RocketController rocket = hit.transform.GetComponent <RocketController>();

            if (hit.transform.tag == "Droid")
            {
                droid.TakeDamage(damage);
                currentScore += droidScoreValue;
            }
            if (hit.transform.tag == "Rocket")
            {
                rocket.TakeDamage(damage);
                currentScore += rocketScoreValue;
            }
        }
        GameObject impact = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));

        impact.GetComponent <ParticleSystem>().Play();
        Destroy(impact, 2f);
    }
Example #8
0
    public override void OnInspectorGUI()
    {
        RocketController rc = (RocketController)target;

        DrawDefaultInspector();
        GUILayout.Label("VelcityAngle: " + rc.VelocityAngle);
    }
 // Use this for initialization
 void Start()
 {
     launchPad        = GameObject.FindObjectOfType <LaunchPad>();
     launchPosition   = launchPad.transform.position + new Vector3(launchPosition.x, 3, launchPosition.z);
     rocketController = GameObject.FindObjectOfType <RocketController>();
     levelManager     = GameObject.FindObjectOfType <LevelManager>();
 }
 private void Awake()
 {
     _body          = this.GetComponent <Rigidbody2D>();
     _target        = _pivot.position;
     _last_position = this.transform.position;
     Instance       = this;
 }
Example #11
0
 // Use this for initialization
 void Start()
 {
     rocket = FindObjectOfType <RocketController> ();
     StartCoroutine(startMission());
     StartCoroutine(addPitch());
     StartCoroutine(initLanding());
 }
Example #12
0
 protected virtual void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         con.PlanetOn = null;
         con          = null;
     }
 }
Example #13
0
 // Start is called before the first frame update
 void Start()
 {
     rocket = FindObjectOfType <RocketController>();
     this.launchButton.interactable = false;
     //this.GetComponent<>
     this.wallet = GameObject.Find("Wallet").GetComponent <Wallet>();
     //this.losePopup = GameObject.Find("LosePopup");
 }
Example #14
0
    private IEnumerator Startdelay()
    {
        yield return(new WaitForSeconds(1.0f));

        rocketController  = Rockt2D.GetComponent <RocketController>();
        SideTrustEmission = GameObject.Find("SideThrustJet").GetComponent <ParticleSystem>().emission;
        Right             = true;
    }
 private void Awake()
 {
     rocketController       = GetComponent <RocketController>();
     initialAcceleration    = rocketController.GetProfile().x;
     initialMaxSpeed        = rocketController.GetProfile().y;
     initialRotationalSpeed = rocketController.GetProfile().z;
     instance = this;
 }
    public void ResetPlayer()
    {
        var oldRocket = GameObject.FindObjectOfType <RocketController>();

        Destroy(oldRocket.gameObject);
        var newPlayer = Instantiate(rocketPrefab, launchPosition, Quaternion.identity);

        rocketController = newPlayer.GetComponent <RocketController>();
    }
Example #17
0
 void Start()
 {
     //joystickPosition = RectTransformUtility.WorldToScreenPoint(cam, background.position);
     joystickPosition = RectTransformUtility.WorldToScreenPoint(cam, GetComponent <RectTransform>().anchoredPosition);
     rocketScript     = GameObject.Find("rocket").GetComponent <RocketController>();
     //rocketScript.setPivot(joystickPosition);
     rocket = GameObject.Find("rocket");
     //mainCamera = GameObject.Find("MainCamera").GetComponent<Camera>();
 }
Example #18
0
 void Start()
 {
     //joystickPosition = RectTransformUtility.WorldToScreenPoint(cam, background.position);
     joystickPosition = RectTransformUtility.WorldToScreenPoint(cam, GetComponent <RectTransform>().anchoredPosition);
     //Debug.Log(joystickPosition);
     rocketScript = GameObject.Find("rocket").GetComponent <RocketController>();
     rocketScript.setPivot(joystickPosition);
     jumpScript = GameObject.Find("Jump").GetComponent <JumpButton>();
 }
 public void InstantiateRockets()
 {
     //Loop through all TrainingUnits
     for (int i = 0; i < trainingUnits.Length; i++)
     {
         RocketController newRocketController = Instantiate(rocketPrefab, trainingUnits[i].transform, false).GetComponent <RocketController>();
         rocketController.Add(newRocketController);
     }
 }
Example #20
0
 protected virtual void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         con           = collision.GetComponentInParent <RocketController>();
         playerInitPos = (transform.position - con.transform.position).sqrMagnitude;
         con.PlanetOn  = this;
     }
 }
Example #21
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.tag == "Player")
     {
         RocketController rocketController = coll.gameObject.GetComponent <RocketController>();
         rocketController.addFuel(5);
         Destroy(this.gameObject);
     }
 }
Example #22
0
    public void LaunchRocket()
    {
        GameObject       rocketObject = Instantiate(rocketPrefab, rigidbody2d.position + lookDirection * new Vector2(0.5f, 0.5f), lookRotation);
        RocketController rocket       = rocketObject.GetComponent <RocketController>();

        rocket.SetLauncherGameObject(this);
        rocket.SetRocketDamage(rocketDamage);
        rocket.Launch(lookDirection, rocketSpeed);
    }
Example #23
0
 private void AddRocket()
 {
     for (int i = 0; i < NumOfRockets; i++)
     {
         RocketController rocket = Instantiate(rocketPrefab, barrel.position, barrel.rotation, null).GetComponent <RocketController>();
         rocket.Init(this);
         rockets.Add(rocket);
     }
 }
Example #24
0
    public void fireRocket()
    {
        Quaternion       rot        = transform.localRotation * Quaternion.Euler(0, 270, 0);
        GameObject       rocket     = (GameObject)Instantiate(rocketPrefab, transform.position, rot);
        RocketController controller = rocket.GetComponent <RocketController>();

        controller.ignore = gameObject;
        controller.target = otherSquid;
        controller.homing = powerupAimed;
    }
 void Start()
 {
     rocket           = GameObject.Find("Rocket");
     rocketController = rocket.GetComponent <RocketController>();
     rocketController.StartFire();
     rocketRb          = rocket.GetComponent <Rigidbody2D>();
     rocketRb.bodyType = RigidbodyType2D.Static;
     restartLabel.gameObject.SetActive(false);
     scoreLabel.gameObject.SetActive(false);
 }
Example #26
0
 private void Start()
 {
     PlayerLifes = GetComponentInChildren <PlayerLifesController>();
     Score       = GetComponentInChildren <ScoreController>();
     Level       = GetComponentInChildren <LevelController>();
     Wave        = GetComponentInChildren <WaveController>();
     Slider      = GetComponentInChildren <Slider>();
     SetSliderValues(5);
     Rocket = GetComponentInChildren <RocketController>();
 }
Example #27
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "rocket")
     {
         RocketController rocket = collision.gameObject.GetComponent <RocketController>();
         rocket.Hit();
         GameObject explosion = (GameObject)Instantiate(explosionObject, transform.position, Quaternion.identity);
         explosion.GetComponent <Animator>().Play("Boom");
         Destroy(gameObject);
     }
 }
Example #28
0
    private void ExplodeRocket(RocketController rocket)
    {
        if (!serverMode)
        {
            rocket.Explode();
        }

        rocketControllers.Remove(rocket);
        gamePieces.Remove(rocket.gameObject);
        Destroy(rocket.gameObject);
    }
    public void VisualizeMissionStart()
    {
        var camera = Camera.main;

        // Init rocket visuals
        rocketParent = Instantiate(RocketPrefab, VisualizationParent.transform, false);
        rocketBottom = rocketParent.transform.Find("RocketBottom").gameObject;
        rocketMid    = rocketParent.transform.Find("RocketMid").gameObject;
        rocketTop    = rocketParent.transform.Find("RocketTop").gameObject;

        rocketController = rocketParent.GetComponent <RocketController>();
    }
Example #30
0
 public void RemoveRocket(RocketController rocket)
 {
     for (int i = 0; i < existedRockets.Count; i++)
     {
         if (existedRockets[i] == rocket)
         {
             Destroy(existedRockets[i].gameObject);
             existedRockets.RemoveAt(i);
             i--;
         }
     }
 }
    // Use this for initialization
    void Start()
    {
        timeSpan = TimeSpan.FromSeconds(-10.0);
        playerHandler = player.GetComponent<RocketController>();

        originalPlayerDotPosition = miniMapPosition.position;
    }