Exemplo n.º 1
0
    void Shoot(int index)
    {
        if (stats.player.Spells[index]._archetype == "Projectile")
        {
            GameObject obj = Instantiate(stats.player.Spells[index]._prefab, transform.position, Quaternion.LookRotation(VectorMousePoint.MousePoint() - this.transform.position));
            print(stats.player.Spells[index]._name);
            obj.GetComponent <Projectile>().RecieveParameters(stats.player.Name, stats.player.Spells[index]._speed, stats.player.Spells[index]._damage, stats.player.Spells[index]._duration, stats.player.Spells[index]._meter, stats.player.Spells[index]._aggro, stats.player.Spells[index]._explodes, stats.player.Spells[index]._size, stats.player.Spells[index]._aoePrefab, stats.player.Spells[index]._buff);
        }
        if (stats.player.Spells[index]._archetype == "Melee")
        {
            GameObject obj = Instantiate(stats.player.Spells[index]._prefab, transform.position + transform.up * 1, Quaternion.LookRotation(VectorMousePoint.MousePoint() - this.transform.position));

            //This attempts to assign the instantiated object as a child of the player object. Currently finds the player object by name, which is set to "mr2" at runtime.
            obj.transform.parent = GameObject.Find("Cube").transform;
            GameObject.Find("Cube").transform.Rotate(new Vector3(90, 0, 0), Space.Self);
            //Prints the name of the spell, for debugging, to make sure we've imported the right one to the right hotkey.
            print(stats.player.Spells[index]._name);
            obj.GetComponent <Melee>().RecieveParameters(stats.player.Name, stats.player.Spells[index]._damage, stats.player.Spells[index]._isCleave, stats.player.Spells[index]._meter, stats.player.Spells[index]._aggro, stats.player.Spells[index]._buff);
        }
        if (stats.player.Spells[index]._archetype == "Aoe")
        {
            GameObject obj = Instantiate(stats.player.Spells[index]._prefab, VectorMousePoint.MousePoint(), Quaternion.identity);
            print(stats.player.Spells[index]._name);
            obj.GetComponent <Aoe>().RecieveParameters(stats.player.Name, stats.player.Spells[index]._damage, stats.player.Spells[index]._meter, stats.player.Spells[index]._aggro, stats.player.Spells[index]._size, stats.player.Spells[index]._buff);
        }
        if (stats.player.Spells[index]._archetype == "Buff")
        {
            stats.player.Buffs.Add(stats.player.Spells[index]);
            GameObject.Find("buffIcon").GetComponentInChildren <Image> ().fillAmount = 1;
            currentBuffTimes[stats.player.Buffs.Count - 1] = stats.player.Buffs[stats.player.Buffs.Count - 1]._duration;
        }
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     GetInput();
     Move();
     //Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.z, 10);
     //Vector3 lookPos = Camera.main.ScreenToWorldPoint(mousePos);
     //lookPos = lookPos - transform.position;
     //float angle = Mathf.Atan2(lookPos.y, lookPos.x) * Mathf.Rad2Deg;
     transform.rotation = Quaternion.LookRotation(VectorMousePoint.MousePoint() - this.transform.position);
 }