Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        //toggled = false;

        rendererer    = GetComponent <Renderer>();
        parentsoldier = GetComponentInParent <UNITinfo>();
    }
Exemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        manager = FindObjectOfType <ManagerScript>();
        health  = GetComponent <UNITinfo>().health;
        uninfo  = GetComponent <UNITinfo>();

        uninfo.iscommandcenter = true;
    }
Exemplo n.º 3
0
    public void ShootEnemy(UNITinfo enemy)
    {
        if (enemy != null && Time.time >= nextimetofire)
        {
            print("bang enemy");

            uinfo.muzzleflash.Play();
            uinfo.gunsound.Play();
            enemy.health -= damage;

            nextimetofire = Time.time + gundelay;
            print(nextimetofire);
        }
    }
Exemplo n.º 4
0
    public void PlaceMoveOrder()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            Ray        ray = camera.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit2;



            if (managerblock.currentselectedunits != null && Physics.Raycast(ray, out hit2))
            {
                print("placing move orders");

                if (managerblock.currentmoveorder != null)
                {
                    print("destroying");
                    Destroy(managerblock.currentmoveorder);
                }

                //GameObject moveorder = Instantiate(movetoherecube, hit2.point, Quaternion.LookRotation(hit2.normal));

                foreach (GameObject unit in managerblock.currentselectedunits)
                {
                    UNITinfo uninfo = unit.GetComponent <UNITinfo>();
                    if (uninfo != null)
                    {
                        //DummyMoveHere dummov = unit.GetComponentInChildren<DummyMoveHere>();
                        uninfo.destination = hit2.point;


                        if (uninfo.destination == null)
                        {
                            print("ERROR, MOVE ORDER NOT FOUND");
                            print(unit);
                        }

                        //dummov.gameObject.transform.SetPositionAndRotation(hit2.point, dummov.transform.rotation);
                        //dummov.gameObject.SetActive(true);
                    }
                }

                //managerblock.currentmoveorder = moveorder;
                //managerblock.curmovordtransform = moveorder.transform;
            }
        }
    }
Exemplo n.º 5
0
 public void DeSelectAll()
 {
     try
     {
         while (managerblock.currentselectedunits[0] != null && managerblock.currentselectedunits[1] != null)
         {
             foreach (GameObject unit in managerblock.currentselectedunits)
             {
                 UNITinfo uninfo = unit.GetComponent <UNITinfo>();
                 if (managerblock.currentselectedunits.Contains(unit))
                 {
                     managerblock.currentselectedunits.Remove(unit);
                     uninfo.ForceDeSelect();
                 }
             }
         }
     }
     catch
     {
     }
 }
Exemplo n.º 6
0
 // Start is called before the first frame update
 void Start()
 {
     uinfo       = gameObject.GetComponent <UNITinfo>();
     sphererange = GetComponentInChildren <SphereCollisionDetection>();
 }
Exemplo n.º 7
0
    private void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            try
            {
                if (curbuilding == true)
                {
                    cammov.Construct(true, "Iron Factory");
                    curbuilding = false;
                }


                Ray        ray = camera.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                print("Yeeted the ray");

                if (Physics.Raycast(ray, out hit) && hit.transform.GetComponent <UNITinfo>())
                {
                    print("ray: " + ray);

                    selectedunitinfo = hit.transform.GetComponent <UNITinfo>();

                    if (!managerblock.currentselectedunits.Contains(hit.transform.gameObject) && selectedunitinfo.selected != true && selectedunitinfo.iscommandcenter == false)
                    {
                        managerblock.currentselectedunits.Add(hit.transform.gameObject);
                        selectedunitinfo.SelectUnit();
                    }
                    else
                    {
                        if (managerblock.currentselectedunits.Contains(hit.transform.gameObject) && selectedunitinfo.selected == true && selectedunitinfo.iscommandcenter == false)
                        {
                            managerblock.currentselectedunits.Remove(hit.transform.gameObject);
                            selectedunitinfo.SelectUnit();
                        }
                        else
                        {
                            print("It could just be a command center calm down");
                            if (selectedunitinfo.iscommandcenter == false)
                            {
                                print("Ok well now we are f****d...");
                            }
                            else
                            {
                                print("Ok! We good!");
                            }
                        }
                    }
                }
                else
                {
                    if (hit.transform.GetComponent <TreeDestruction>())
                    {
                        print("destroying tree");

                        TreeDestruction td = hit.transform.GetComponent <TreeDestruction>();
                        td.DestroyTree();

                        print(td);
                    }
                    else
                    {
                        if (curbuilding == true)
                        {
                            if (selectedbuilding == "Iron Factory")
                            {
                                if (managerblock.Iron >= 6)
                                {
                                    Instantiate(IronFactory, hit.transform.position, hit.transform.rotation);
                                    managerblock.Iron -= 6;
                                    curbuilding        = false;

                                    print("Building Location" + hit.transform);
                                }
                                else
                                {
                                    print("Broke much?");
                                }
                            }
                        }
                        else
                        {
                            cammov.PlaceMoveOrder();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                print("SelectUNIT script error:" + e);
            }
        }
    }