예제 #1
0
    public void Awake()
    {
        for (int i = 0; i < transform.childCount; i++)
        {
            CubesLoc.Add(transform.GetChild(i).gameObject);
        }
        if (ConstructDirectory.IsLoaded == false)
        {
            ConstructDirectory.Load();
        }
        ConstructDisplayed = new ConstructData();
        ConstructDisplayed = ConstructDirectory.GetRandom();
        List <GameObject> SentCubes = new List <GameObject>();

        for (int i = 0; i < CubesLoc.Count; i++)
        {
            if (i < ConstructDisplayed.RequiredCubes)
            {
                CubesLoc[i].SetActive(true);
                SentCubes.Add(CubesLoc[i]);
            }
            else
            {
                CubesLoc[i].transform.position = transform.position;
                CubesLoc[i].SetActive(false);
            }
        }
        ConstructDisplayed.SetUp(this.transform, 0);
        ConstructDisplayed.ChangeInto(SentCubes);
    }
    public void BuildControlles()
    {
        if (subject != null)
        {
            subject.transform.position = Owner.transform.position + ((Owner.transform.forward * 8) + Owner.transform.up * 10);
        }
        if (Input.GetKeyDown(KeyCode.O))
        {
            if (Mode == BuildMode.Turrets)
            {
                if (Ttype != TurretTypes.last && subject == null)
                {
                    Debug.Log("Getting Turret");
                    subject = ConstructDirectory.GetTurret(Ttype);
                }
                else
                {
                    if (subject.GetComponent <IPlaceableObj>().Place(subject.transform.position))
                    {
                        subject = null;
                    }
                }
            }
            else if (Mode == BuildMode.Wall)
            {
                Ray r = new Ray(Owner.transform.position + Owner.transform.forward * 8, Vector3.down);
                Debug.Log("Click: " + r.origin);
                RaycastHit hit;
                Debug.DrawRay(r.origin, r.direction * 10f, Color.red);
                if (Physics.Raycast(r, out hit, Mathf.Infinity))
                {
                    Debug.Log("Hit.");

                    IClickable c = hit.collider.gameObject.GetComponent <IClickable>();
                    if (c != null)
                    {
                        Debug.Log("Click action: " + hit.point);
                        c.ClickAction(hit.point);
                    }
                }
            }
            else
            {
                Debug.Log("Error Build mode not set correctly");
            }
        }
        else if (Input.GetKeyDown(KeyCode.P))
        {
            if (subject != null)
            {
                GameObject.Destroy(subject.gameObject);
                subject    = null;
                isBuilding = false;
                Mode       = BuildMode.last;
            }
        }
    }
예제 #3
0
 void Shoot()
 {
     Bullet = null;
     Temp   = ConstructDirectory.GetProjectile(ProjectileName.Bullet);
     Bullet = Temp.gameObject;
     Temp   = null;
     Bullet.GetComponent <Projectile>().initialize(Owner.gameObject, Barrel.transform, AttackDamage, ThrowPower, angle, projectileType.Normal, Allegiance.Player, ProjectileName.Bullet, 0f);
     timer = fireRate;
     Bullet.GetComponent <Projectile>().Launch();
 }
 void Shoot()
 {
     Temp   = ConstructDirectory.GetProjectile(ProjectileName.Hammer);
     Hammer = Temp.gameObject;
     Hammer.transform.parent = rightHand.transform;
     Temp = null;
     Hammer.GetComponent <Projectile>().initialize(Owner.gameObject, rightHand.transform, AttackDamage, ThrowPower, angle, projectileType.Normal, Allegiance.Player, ProjectileName.Hammer, 19.81f);
     Hammer.GetComponent <Projectile>().Launch();
     Hammer = null;
     timer  = fireRate;
 }
예제 #5
0
 void Awake()
 {
     rb = GetComponent <Rigidbody>();
     if (PlayerList == null)
     {
         PlayerList = new List <CubePlayer>();
         Players    = new string[4];
     }
     AssignPlayer();
     DontDestroyOnLoad(this.gameObject);
     for (int i = 0; i < transform.childCount; i++)
     {
         if (gameObject.transform.GetChild(i).gameObject.tag == "Cube")
         {
             CubesLoc.Add(gameObject.transform.GetChild(i).gameObject);
         }
     }
     if (ConstructDirectory.IsLoaded == false)
     {
         ConstructDirectory.Load();
     }
     ConstructsObtained    = new ConstructData[4];
     ConstructsObtained[0] = (ConstructDirectory.Find(ConstructType.CubeGuy));
     ConstructsObtained[1] = (ConstructDirectory.Find(ConstructType.Turret));
     ConstructsObtained[2] = (ConstructDirectory.Find(ConstructType.Car));
     ConstructsObtained[3] = (ConstructDirectory.Find(ConstructType.Tank));
     SentCubes             = new List <GameObject>();
     Menu = new MenuControl(MenuObj, this);
     for (int i = 0; i < CubesLoc.Count; i++)
     {
         if (i < ConstructsObtained[0].RequiredCubes)
         {
             SentCubes.Add(CubesLoc[i]);
         }
         else
         {
             CubesLoc[i].transform.position = transform.position;
             CubesLoc[i].SetActive(false);
         }
     }
     CurrentConstruct = ConstructsObtained[0];
     CurrentConstruct.SetUp(this.transform, PlayerNum);
     CurrentConstruct.ChangeInto(SentCubes);
 }