Пример #1
0
    // Use this for initialization
    void Start()
    {
        ship       = transform.parent.gameObject.GetComponent <JPShip>();
        parentShip = transform.parent.gameObject.GetComponent <JPShip>();

        maxHeath     = ship.maxHealth;
        numSegments  = maxHeath / segmentValue;
        segmentWidth = ((segmentValue * 10f) / maxHeath) * 4f;
        //print(""+segmentValue + " " + " " + maxHeath + " " + ((segmentValue * 10) / maxHeath));

        indicators = new GameObject[(int)numSegments];
        for (int count = 0; count < numSegments; count++)
        {
            indicators[count] = (GameObject)Instantiate(healthIndicator, transform.position, transform.rotation);
            indicators[count].transform.parent = transform;
            Vector3 pos = indicators[count].transform.localPosition;
            pos.x = (count * (segmentWidth + (segmentWidth * 0.1f)));
            //Debug.Log("" + (count * (segmentWidth + (segmentWidth * 0.1f))));
            Vector3 scale = indicators[count].transform.localScale;
            scale.y = 4;
            scale.z = 2;
            scale.x = segmentWidth;
            indicators[count].transform.localPosition = pos;
            indicators[count].transform.localScale    = scale;
        }
        text = GetComponent <TextMesh>();
    }
Пример #2
0
 public void RpcSetLeadController(string leadName, int playerNum, int shipNum, int maxNum)
 {
     //print("rpc leadcontroller set called " + leadName);
     leadController = GameObject.Find(leadName).GetComponent <JPShip>();
     if (leadName != gameObject.name)
     {
         lead = false;
     }
     for (int count = 0; count < maxNum; count++)
     {
         wingmen[count] = GameObject.Find("Player" + playerNum + "Ship" + shipNum + "Squad" + count);
     }
 }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        range          = transform.parent.GetComponent <DRange>();
        angle          = transform.rotation;
        laserShoot     = GetComponentsInChildren <LaserShoot>();
        startVector    = transform.localRotation.eulerAngles;
        startRotation  = transform.localRotation;
        shipController = transform.parent.parent.gameObject.GetComponent <JPShip>();

        foreach (LaserShoot laser in laserShoot)
        {
            laser.teamNum = shipController.teamNum;
        }
    }
Пример #4
0
 public void CmdRetreat()
 {
     for (int count = 0; count < spawnedShipList.Length; count++)
     {
         JPShip temp = spawnedShipList[count].GetComponent <JPShip>();
         for (int countInner = 0; countInner < temp.wingmen.Length; countInner++)
         {
             temp.wingmen[countInner].GetComponent <JPShip>().JumpToLocation(new Vector3(1000f, 0f, 10000f), false);
             if (!temp.wingmen[countInner].GetComponent <JPShip>().destroyed)
             {
                 DecrementFleetHealth(temp.wingmen[countInner].GetComponent <JPShip>().shipValue);
             }
         }
     }
 }
Пример #5
0
    // RaycastAll & loop through objects hit
    public void FireBeam(Vector3 origin, Vector3 direction)
    {
        // spawn particles?
        Ray ray = new Ray(origin, direction);

        RaycastHit[] hits = Physics.RaycastAll(ray, beamRange);
        foreach (RaycastHit r in hits)
        {
            // Deal damage to ships hit
            JPShip ship = r.collider.gameObject.GetComponent <JPShip>();
            if (ship != null)
            {
                ship.health -= (int)beamDamage;
            }
        }
    }
Пример #6
0
 // Use this for initialization
 void Start()
 {
     //defaultMaterial = this.transform.GetChild(0).GetChild(0).GetComponent<Renderer>().material;
     if (lead)
     {
         leadController = this;
     }
     offset = wingmenOffsets[squadNum];
     health = maxHealth;
     if (forceHPShow)
     {
         hpShow.SetActive(true);
     }
     if (!isServer)
     {
         GetComponent <Collider>().isTrigger = true;
     }
     //hpShow = transform.Find("HP").gameObject;
     //hpShow.SetActive(false);
 }
Пример #7
0
    private void OnTriggerStay(Collider other)
    {
        if (!isServer)
        {
            return;
        }
        if (other.gameObject.GetComponent <JPShip>())
        {
            JPShip ship = other.gameObject.GetComponent <JPShip>();
            if (ship.teamNum == teamNum)
            {
                if (ship.health < ship.maxHealth)
                {
                    ship.health += (int)healAmount;
                }

                ship.moveSpeed += speedAmount;
                //print(other.gameObject.name);
            }
        }
    }
Пример #8
0
 // Use this for initialization
 void Start()
 {
     ship = GetComponent <JPShip>();
 }