コード例 #1
0
ファイル: BulletManager.cs プロジェクト: mbiesenb/JeffAround
    public void AddBullet(GameObject bullet)
    {
        // TODO: calc angle
        GameObject  newBullet        = Instantiate(bullet, new Vector3(0, 0, 1), Quaternion.identity);
        OrbitAround bulletComponent  = (OrbitAround)newBullet.GetComponent <OrbitAround>();
        GameObject  newBullet2       = Instantiate(bullet, new Vector3(0, 0, 1), Quaternion.identity);
        OrbitAround bulletComponent2 = (OrbitAround)newBullet2.GetComponent <OrbitAround>();

        /*CBACBA
        *  CBACBA*/
        int index = bullets.Count / 2;

        bullets.Insert(index, bulletComponent);
        bullets.Insert(0, bulletComponent2);

        float angleBetweenBullets = Mathf.PI * 2 / bullets.Count;

        Debug.Log("My Name is jeff");
        for (int i = 0; i < bullets.Count; i++)
        {
            bullets[i].currentAngle = i * angleBetweenBullets;
        }

        /*GameObject newBullet = Instantiate(bullet, new Vector3(0, 0, 1), Quaternion.identity);
         * OrbitAround bulletComponent = (OrbitAround)newBullet.GetComponent<OrbitAround>();
         * bullets.Add(bulletComponent);
         * float angleBetweenBullets = Mathf.PI * 2 / bullets.Count;
         * Debug.Log("My Name is jeff");
         * for (int i = 0; i < bullets.Count; i++)
         * {
         *  bullets[i].currentAngle = i * angleBetweenBullets;
         * }*/
    }
コード例 #2
0
    private void Awake()
    {
        _oa = GetComponent <OrbitAround>();

        if (_oa == null)
        {
            throw new NullReferenceException("Orbit around component must not be null");
        }
    }
コード例 #3
0
 protected override void OnAwake()
 {
     base.OnAwake();
     this.Info = new ActorInfo()
     {
         Name = "Tank",
         HitChance = 33,
         BlockChance = 25,
         Cooldown = 5,
         Reboots = 1
     };
     LineRenderer.SetVertexCount(0);
     OrbitScript = this.GetComponent<OrbitAround>();
 }
コード例 #4
0
 protected override void OnAwake()
 {
     this.IsLurking = true;
     base.OnAwake();
     this.Info = new ActorInfo()
     {
         Name = "Stealth Virus",
         Cooldown = 1f,
         HitChance = 20,
         BlockChance = 25
     };
     OrbitScript = this.GetComponent<OrbitAround>();
     this.RenderBottleneck.gameObject.SetActive(!IsLurking);
 }
コード例 #5
0
    // Use this for initialization
    void Start()
    {
        int rand, j;

        int[] rands;

        GUIroids = GameObject.Find("Debug GUI/nbRoids");
        text     = GUIroids.GetComponent(typeof(GUIText)) as GUIText;

        usedDistances = new int[2];

        // Génération d'une, deux, ou trois ceintures d'astéroides (60%, 30%, 10%)
        rand = Random.Range(0, 10);
        if (rand == 0)
        {
            nbBelts = 3;
        }
        else if (rand > 0 && rand <= 3)
        {
            nbBelts = 2;
        }
        else
        {
            nbBelts = 1;
        }
        nbBelts  = 3;
        belts    = new GameObject[nbBelts];
        spawners = new GameObject[nbBelts];
        rands    = new int[nbBelts];

        for (int i = 0; i < nbBelts; i++)
        {
            rand     = Random.Range(50, 150);
            rands[i] = rand;
            belts[i] = new GameObject("Belt" + (i + 1));
            OrbitAround orbit = belts[i].AddComponent <OrbitAround>() as OrbitAround;
            if (Random.Range(0, 2) == 0)
            {
                orbit.Init("belt", 0.002f, GameObject.FindGameObjectWithTag("Sun"));
            }
            else
            {
                orbit.Init("belt", -0.002f, GameObject.FindGameObjectWithTag("Sun"));
            }

            do
            {
                boolDistanceOK = false;

                for (j = 0; j < nbBelts; j++)
                {
                    if (j != i && rands[j] != 0)
                    {
                        if ((rands[j] - rand < 30 && rands[j] - rand > 0) ||
                            (rands[j] - rand > -30 && rands[j] - rand < 0))
                        {
                            boolDistanceOK = true;
                        }
                        else
                        {
                            rand           = Random.Range(50, 150);
                            rands[i]       = rand;
                            boolDistanceOK = false;
                        }
                    }
                    else
                    {
                        boolDistanceOK = true;
                    }
                }
            }while(!boolDistanceOK);

            spawners[i] = new GameObject();
            spawners[i].GetComponent <Transform>().position = new Vector3(rand, 0, 0);
            spawners[i].transform.parent = belts[i].transform;
            orbit = spawners[i].AddComponent <OrbitAround>() as OrbitAround;
            orbit.Init("spawner", 0.5f, GameObject.FindGameObjectWithTag("Sun"));

            StartCoroutine("spawnAsteroidsAround", i);
        }

        for (int h = 0; h < nbBelts; h++)
        {
            Debug.Log("rand " + h + " : " + rands[h]);
        }
    }