예제 #1
0
    public void PrepareShipForLevelLoad()
    {
        Dictionary <GameObject, IList <GameObject> > graph = shipGraph.Graph;

        foreach (GameObject key in graph.Keys)
        {
            foreach (GameObject value in graph[key])
            {
                JointScript.Attach(key, value);
            }

            key.collider.isTrigger = false;
            Destroy(key.GetComponent <ShipEditorScript>());

            key.AddComponent <DamageOnCollisionScript>();
            key.AddComponent <Enforce2DBehaviourScript>();


            DontDestroyOnLoad(key);
            if (key.tag == "Engine")
            {
                key.AddComponent <ThrusterScript>();
                ThrusterScript thrusterScript = key.GetComponent <ThrusterScript>();
                KeyScript      keyScript      = key.GetComponent <KeyScript>();

                thrusterScript.setKeyCode(keyScript.key);
                Destroy(keyScript);
                Destroy(key.transform.Find("EngineKeyText").gameObject);
            }
        }
    }
예제 #2
0
 private void Start()
 {
     lu   = leftUp.GetComponent <ThrusterScript>();
     ld   = leftDown.GetComponent <ThrusterScript>();
     ru   = rightUp.GetComponent <ThrusterScript>();
     rd   = rightDown.GetComponent <ThrusterScript>();
     mass = GetComponent <Rigidbody2D>().mass;
 }
예제 #3
0
 // Use this for initialization
 void Start()
 {
     animator = GetComponent <Animator>();
     //ustawienie podstawowego stanu
     landerState = new LanderIdle(this);
     mainEngine  = new ThrusterScript(fuelrate, enginepower); //inicjacja silnika
     gamecontrol = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();
     //inicjacja paliw
     fuel     = startingfuel;
     monoprop = startingmonoprop;
 }
예제 #4
0
 private void Awake()
 {
     mts = mainThruster.GetComponent <ThrusterScript>();
     frr = frrO.GetComponent <ThrusterScript>();
     fru = fruO.GetComponent <ThrusterScript>();
     fll = fllO.GetComponent <ThrusterScript>();
     flu = fluO.GetComponent <ThrusterScript>();
     brr = brrO.GetComponent <ThrusterScript>();
     brd = brdO.GetComponent <ThrusterScript>();
     bll = bllO.GetComponent <ThrusterScript>();
     bld = bldO.GetComponent <ThrusterScript>();
 }
 void Start()
 {
     radarTime.SetTimer(25.0f);
     autoStopTime.SetTimer(15.0f);
     laserTime.SetTimer(10.0f);
     myThruster = GetComponent <ThrusterScript>();
     myHealthBar.OnSpawn(health, healthMax);
     mylaserBar.OnSpawn(laser, laserMax);
     if (myWatchLaserBar != null)
     {
         myWatchLaserBar.SetLinearBarExtremes();
         myWatchLaserBar.SetBar(laser, laserMax);
     }
     myHotRods = GetComponentsInChildren <DetachableObject>();
     invulTimer.SetTimer(1.0f);
     hitEffectTimer.SetTimer(0.5f);
     myColliders = GetComponentsInChildren <Collider>();
 }
예제 #6
0
    /// <summary>
    /// Uses thruster to dodge.
    /// </summary>

    void thrusterDodge()
    {
        Vector3 mouseIn   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        float   relativeX = mouseIn.x - transform.position.x;
        float   relativeY = mouseIn.y - transform.position.y;

        ThrusterScript thruster = gameObject.GetComponentInChildren <ThrusterScript> ();

        if (thruster != null)
        {
            thruster.Push(relativeX, relativeY, mouseIn);
        }
        // Finds the relative x and y direction, adds a speed modifier, but caps it at a certain speed.
        movement = new Vector2(
            speedModifier * relativeX,
            speedModifier * relativeY);
        // 6 - Move the game object
        GetComponent <Rigidbody2D>().AddForce(movement);
        // Resets the cooldown.
        thrusterCurrCD = thrustCD;
    }
예제 #7
0
    void Awake()
    {
        playerScript = gameObject.GetComponent <PlayerScript> ();
        if (playerScript == null)
        {
            Debug.LogError("Aaron Says: No PlayerScript Instantiated in Cutscene Script!");
        }

        thrusterScript = gameObject.GetComponentInChildren <ThrusterScript> ();
        if (thrusterScript == null)
        {
            Debug.LogError("Aaron Says: No ThrusterScript Instantiated in Cutscene Script!");
        }

        timerScript = GameObject.Find("Timer").GetComponent <SurvivalTimerScript> ();
        if (timerScript == null)
        {
            Debug.LogError("Aaron Says: No ThrusterScript Instantiated in Cutscene Script!");
        }

        AudioSource.PlayClipAtPoint(warpSFX, transform.position);
    }
예제 #8
0
 public ThrusterWrapper(GameObject gameObject)
 {
     this.gameObject = gameObject;
     this.script     = gameObject.GetComponent <ThrusterScript>();
 }