Пример #1
0
    private void Start()
    {
        selection = GetComponent <SelectionScript>();
        GameObject controlAverage = new GameObject("Control Average");

        this.controlAverage = controlAverage.transform;
    }
Пример #2
0
        public override void OnUpdate()
        {
            attackScript    = (AttackScript)GameObject.Find("WeaponAnimator").GetComponent(typeof(AttackScript));
            selectionScript = (SelectionScript)GameObject.Find("WeaponAnimator").GetComponent(typeof(SelectionScript));
            if (selectionScript.selectedweapon == 1 && (!semiAuto.Value && Input.GetKey(KeyCode.Mouse0)) || (semiAuto.Value && Input.GetKeyDown(KeyCode.Mouse0)))
            {
                switch (projectile.Selected)
                {
                case "BULLET":
                    attackScript.shootbullet(inaccuracy.GetValueFloat(), 1000f, shotNum.GetValueInt(), damage.GetValueFloat(), 1, speed.GetValueFloat(), upPower.GetValueFloat(), doricnoise.Value, ignoreTracers.Value, 1);
                    break;

                case "ARROW":
                    attackScript.throwprojectile(0, speed.GetValueFloat(), shotNum.GetValueFloat(), inaccuracy.GetValueFloat());
                    break;

                case "RIVET":
                    attackScript.throwprojectile(1, speed.GetValueFloat(), shotNum.GetValueFloat(), inaccuracy.GetValueFloat());
                    break;

                default:
                case "MORTAR":
                    attackScript.throwprojectile(2, speed.GetValueFloat(), shotNum.GetValueFloat(), inaccuracy.GetValueFloat());
                    break;
                }
            }
        }
Пример #3
0
    void MyCollisions()
    {
        boxSelect();
        hitColliders = Physics.OverlapBox((point1 + point2) / 2, new Vector3((B - A) / 2, 2, (D - C) / 2), Quaternion.identity, unitMask);
        Debug.DrawLine(new Vector3(A, 1, C), new Vector3(A, 1, D));
        Debug.DrawLine(new Vector3(B, 1, C), new Vector3(B, 1, D));
        Debug.DrawLine(new Vector3(A, 1, C), new Vector3(B, 1, C));
        Debug.DrawLine(new Vector3(A, 1, D), new Vector3(B, 1, D));

        Debug.DrawLine((point1 + point2) / 2, (point1 + point2) / 2 + new Vector3(B - A / 2, 2, D - C / 2).x *Vector3.right);

        width = (int)Math.Sqrt(hitColliders.Length);
        int i = 0;

        while (i < hitColliders.Length)
        {
            //Debug.Log ("hit : " + hitColliders [i].name + i);
            SelectionScript s = hitColliders [i].GetComponent <SelectionScript> ();
            if (s != null)
            {
                s.selected = true;
            }
            i++;
        }
    }
Пример #4
0
	// Use this for initialization
	void Start () {
		Debug.Log ("Simulation started");
		totemsChosen = false;
		p1TotemScript = player1Totem.GetComponent<Totem_Script>();
		p2TotemScript = player2Totem.GetComponent<Totem_Script>();
		selectionScript = UiSelectionController.GetComponent<SelectionScript>();
		fltgtxtcntrl = FloatingTxtContrlGO.GetComponent<FloatingTextController>();
	}
Пример #5
0
 public override void OnUpdate()
 {
     selectionScript = (SelectionScript)GameObject.Find("WeaponAnimator").GetComponent(typeof(SelectionScript));
     for (int i = 0; i != selectionScript.ammoinventory.Length; i++)
     {
         selectionScript.ammoinventory[i] = Single.MaxValue;
     }
 }
Пример #6
0
    // Use this for initialization
    void Start()
    {
        SELECTION = GameObject.FindGameObjectWithTag("Selections").GetComponent <SelectionScript>();

        selecter  = playerHolder.transform.Find("Selected").gameObject;
        spotlight = playerHolder.transform.Find("Spotlight").gameObject;
        spotCone  = playerHolder.transform.Find("Cone").gameObject;
        spawnPos  = playerHolder.transform.Find("SpawnPos").gameObject;
    }
Пример #7
0
 private void AnimalRemoved(SelectionScript selectionRemove, SignPost signpost)
 {
     for (int i = signpost.animalList.Count -1; i >= 0; i--)
     {
         if(signpost.animalList[i] == selectionRemove)
         {
             signpost.animalList.RemoveAt(i);
         }
     }
 }
Пример #8
0
 private void Refresh()
 {
     for(int i = 0; i < animalList.Count; i++)
     {
         SelectionScript selection = animalList[i];
     }
     for (int b = 0; b < buildingList.Count; b++)
     {
         BuildingScript buildings = buildingList[b];
     }
 }
Пример #9
0
 public void LeftClick()
 {
     if (itemSpot > 0)
     {
         itemSpot--;
         SelectionScript selection = animalList[itemSpot];
         animalText.text = selection.animalName;
         selectedImage.sprite = selection.icon;
         purchaseButton.interactable = true;
         soldOut.SetActive(false);
         NotEnough.enabled = false;
     }
 }
Пример #10
0
 public override void OnUpdate()
 {
     selectionScript = (SelectionScript)GameObject.Find("WeaponAnimator").GetComponent(typeof(SelectionScript));
     GiveKeys();
     GiveAllWeapons();
     if (mode.Selected == "AUTO" && autoUnlimitedAmmo.Value)
     {
         UnlimitedAmmo unlimitedAmmo = (UnlimitedAmmo)Main.ModuleManager.GetModule("UnlimitedAmmo");
         if (!Main.ModuleManager.IsModuleActive(unlimitedAmmo))
         {
             Main.ModuleManager.Toggle(unlimitedAmmo);
         }
     }
     if (mode.Selected == "SINGLE")
     {
         Main.ModuleManager.Toggle(this);
     }
 }
Пример #11
0
    //Initilize
    public void Initialize(
        STDMath math, Generator gen, Assets asset, SelectionScript selec,
        bool active, bool defense, bool ai
        )
    {
        //assign external variables
        map         = gen;
        assetHolder = asset;
        selector    = selec;
        stdMath     = math;
        Random.InitState(stdMath.seed);
        guiCon = GameObject.Find("UI").GetComponent <GUIDriver> ();

        //Sets living or AI player, and defense or offense
        activePlayer = active;
        isAI         = ai;
        onDefense    = defense;

        //Create overlord upgrades
        upgrades = this.gameObject.AddComponent <OverlordUpgrade>();
        upgrades.Init(active, math, this, gen);



        //initialzies per playertype
        if (active)
        {
            quickKeys          = selec.gameObject.GetComponent <QuickKeys>();
            quickKeys.overlord = this;

            //Initialize Gui
            guiCon.InitGUI(this);

            controls = gen.GetControls();
            controls.Init(math, this, gen);

            //set default unit layer
            defualtLayer        = 11;
            defualtLayerOutline = 29;
        }

        //set GameTime starting
        gameTime = Time.time;
    }
Пример #12
0
    // Use this for initialization
    void Start()
    {
        //development bool
        if (!disableGeneration)
        {
            //import Seed
            seed = stdMath.seed;
            Random.InitState(seed);

            //initialize arrays
            blocks     = assetHolder.blocks;
            tileAssets = assetHolder.tileAssets;
            selector   = GameObject.Find("EventSystem").GetComponent <SelectionScript> ();
            quickKeys  = selector.gameObject.GetComponent <QuickKeys> ();
            //	baseMaterials = assetHolder.materials;

            //initialize map and noise map
            map = new int[mapSize, mapSize];

            //create Map
            GenNoise();
            GenMat();
            GenMap();

            //Set objects
            SetCam();

            //Set Players
            GenPlayer();


            //TEMP
            //SetUnit();

            //run dev tools
            if (devTools)
            {
                DevTools();
                //OnDrawGizmos ();
            }
        }
    }
Пример #13
0
 public void ProcessMouseLeftClick()
 {
     if (!oneClick) // first click no previous clicks
     {
         oneClick            = true;
         timerForDoubleClick = Time.time; // save the current time
         if (SelectionScript != null)
         {
             SelectionScript.OneClickActions();
         }
     }
     else
     {
         oneClick = false; // found a double click, now reset
         if (SelectionScript != null)
         {
             SelectionScript.DoubleClickActions();
         }
     }
 }
Пример #14
0
    public void Purchase()
    {
        SelectionScript selection = animalList[itemSpot];
        BuildingScript buildings = buildingList[buildingSpot];

        if (DataHolding.MoneyGained >= selection.price)
        {
            DataHolding.MoneyGained -= selection.price;
            DataHolding.AudienceCount++;
            soldOut.SetActive(true);
            
            buildings.buttons.SetActive(false);
            GameObject animalbuilding = Instantiate(selection.animalBuilding, buildings.spawnPoint.transform.position, Quaternion.Euler(0, 0, 0));
            AnimalRemoved(animalList[itemSpot], this);
            ButtonRemoval(buildingList[buildingSpot], this);
            purchasePanel.SetActive(false);
            Time.timeScale = 1;

            //for (buildingSpot = 0; buildingSpot < buildingList.Count; buildingSpot++)
            //{
            //    if (buildingSpot == 0)
            //    {
                    
            //    }
            //    else if (buildingSpot == 1)
            //    {
            //        BuildingScript buildings = buildingList[buildingSpot];
            //        buildings.buttons.SetActive(false);
            //        GameObject animalbuildin = Instantiate(selection.animalBuilding, buildings.spawnPoint.transform.position, Quaternion.Euler(0, 0, 0));
            //        buildingSpot++;
            //        AnimalRemoved(animalList[itemSpot], this);
            //        purchasePanel.SetActive(false);
            //    }
            //}      
        }
        else
        {
            NotEnough.enabled = true;
        }
    }
Пример #15
0
 public override void OnEnable()
 {
     selectionScript = (SelectionScript)GameObject.Find("WeaponAnimator").GetComponent(typeof(SelectionScript));
     GiveMaxAmmo();
 }
Пример #16
0
    public static List <ObjFuncs.Obj> gridObjs; //Objs that the dragged object is checking against their grids

    public static void InputOrders()            //Called every frame from hl.HlObj Update
    {
        //There is a generic way to do this, but for now, I'm just going to handle each case

        //Make sure that the connection isn't null
        if (hl.hlObj == null)
        {
            return;
        }

        //Get mouse pos in the world
        Vector3    mousePos = Vector3.zero;
        Ray        ray      = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 999, xa.de.toHitFloorMask))
        {
            mousePos = hit.point;
        }

        MouseOrders mouseOrder = MouseOrders.None;

        if (Input.GetMouseButtonDown(0))        //Left click - Drag selection
        {
            //start dragging a selection box
            mouseOrder = MouseOrders.SelectionBox_StartDragging;
        }
        if (Input.GetMouseButtonUp(0))        //Left click up, release dragged object or stop selection box?
        {
            //I wasn't dragging an obj, so I must have been dragging a selection box
            mouseOrder = MouseOrders.SelectionBox_StopDragging;
        }
        SelectionScript.HandleSelection(mouseOrder);        //Handles local selection box

        //Issue a move command to all selected units of the correct player
        if (Input.GetMouseButtonDown(1))        //Move order
        {
            //Send the order to the server. Fire and forget!
            ObjFuncs.Obj o;

            //send one order per unit ordered.
            List <int> result = new List <int>();
            for (int i = 0; i < ObjFuncs.objs.Count; i++)
            {
                o = ObjFuncs.objs[i];
                if (o.isUnit && o.ownedByClId == hl.local_uId && o.selected)
                {
                    result.Add(o.uId);
                }
            }
            int[] unitIds = new int[result.Count];
            for (int i = 0; i < result.Count; i++)
            {
                unitIds[i] = result[i];
            }                                                                             //write to the array

            hl.hlObj.CmdMoveOrder(hl.local_uId, mousePos, unitIds);

            //Trigger local effect
            Effects.MoveOrderEffect(mousePos);
        }

        //This is currently hardwired to specific keys, but later players will be able to rebind.
        if (Input.GetKeyDown(KeyCode.Alpha1))        //Create a command pod!
        {
            ChatScript.ChatLocally("Detected local createObj order: Marine");
            //Send the order to the server
            hl.hlObj.CmdCreateObj(hl.local_uId, mousePos, (int)ObjFuncs.Type.Marine);

            //Trigger local effect
            //Effects.CircleBlip(mousePos, 5, 5);
        }
    }
Пример #17
0
    public static List <ObjFuncs.Obj> gridObjs; //Objs that the dragged object is checking against their grids

    public static void InputOrders()            //Called every frame from hl.HlObj Update
    {
        //There is a generic way to do this, but for now, I'm just going to handle each case

        //Make sure that the connection isn't null
        if (hl.hlObj == null)
        {
            return;
        }

        //Get mouse pos in the world
        Vector3    mousePos = Vector3.zero;
        Ray        ray      = xa.de.globalMainCam.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 999, xa.de.toHitFloorMask))
        {
            mousePos = hit.point;
        }

        MouseOrders mouseOrder = MouseOrders.None;

        if (Input.GetMouseButtonDown(0))        //Left click - Drag selection or drag object?
        {
            //is the mouse over a object that can be dragged?
            draggingObj = -1;
            ray         = xa.de.globalMainCam.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit, 999, xa.de.toHitDraggableObjs))
            {
                //An obj is under the mouse,
                int uId   = hit.collider.gameObject.GetComponent <HitboxScript>().go.GetComponent <Info>().uId;
                int index = ObjFuncs.GetObjIndexForUID(uId);

                //can it be dragged?
                if (!ObjFuncs.objs[index].isUnit && ObjFuncs.objs[index].attachedTo == -1)
                {
                    mouseOrder  = MouseOrders.DraggingObj_Start;
                    draggingObj = uId;
                    ObjFuncs.PickingUpAnObj(draggingObj);
                }
            }


            if (draggingObj == -1)
            {
                //No object under my mouse, so start dragging a selection box
                mouseOrder = MouseOrders.SelectionBox_StartDragging;
            }
        }
        if (Input.GetMouseButtonUp(0))        //Left click up, release dragged object or stop selection box?
        {
            if (draggingObj != -1)            //I was dragging an obj. Drop it.
            {
                //Dropping an object
                mouseOrder = MouseOrders.DraggingObj_Stop;

                ObjFuncs.DroppingAnObj(draggingObj);

                draggingObj = -1;
            }
            else
            {
                //I wasn't dragging an obj, so I must have been dragging a selection box
                mouseOrder = MouseOrders.SelectionBox_StopDragging;
            }
        }
        if (draggingObj != -1)        //Dragging an object
        {
            int index = ObjFuncs.GetObjIndexForUID(draggingObj);
            ObjFuncs.objs[index].go.transform.SetX(mousePos.x);
            ObjFuncs.objs[index].go.transform.SetZ(mousePos.z);

            ObjFuncs.objs[index].visualState[0] = 0;
            int result = ObjFuncs.IfOverValidPos(draggingObj);
            if (result != -1)
            {
                //change color
                ObjFuncs.objs[index].visualState[0] = 1;

                //Align to the possible gridObj's angle
                int gridObjIndex = ObjFuncs.GetObjIndexForUID(result);
                ObjFuncs.objs[index].desiredAngle = ObjFuncs.objs[gridObjIndex].go.transform.localEulerAngles.y;
            }

            //snap to this (tween later)
            ObjFuncs.objs[index].go.transform.SetAngY(ObjFuncs.objs[index].desiredAngle + ObjFuncs.objs[index].gridObjAnglesOffset);

            //detect if the player wants to rotate this object
            if (Input.GetKeyDown(KeyCode.Q))            //Rotate the object
            {
                ObjFuncs.objs[index].gridObjAnglesOffset -= 90;
            }
            if (Input.GetKeyDown(KeyCode.E))            //Rotate the object
            {
                ObjFuncs.objs[index].gridObjAnglesOffset += 90;
            }
        }

        SelectionScript.HandleSelection(mouseOrder);        //Handles local selection box

        //Issue a move command to all selected units of the correct player
        if (Input.GetMouseButtonDown(1))        //Move order
        {
            //Send the order to the server. Fire and forget!
            ObjFuncs.Obj o;

            //send one order per unit ordered.
            List <int> result = new List <int>();
            for (int i = 0; i < ObjFuncs.objs.Count; i++)
            {
                o = ObjFuncs.objs[i];
                if (o.isUnit && o.ownedByClId == hl.local_uId && o.selected)
                {
                    result.Add(o.uId);
                }
            }
            int[] unitIds = new int[result.Count];
            for (int i = 0; i < result.Count; i++)
            {
                unitIds[i] = result[i];
            }                                                                             //write to the array

            hl.hlObj.CmdMoveOrder(hl.local_uId, mousePos, unitIds);

            //Trigger local effect
            Effects.MoveOrderEffect(mousePos);
        }

        //This is currently hardwired to specific keys, but later players will be able to rebind.
        if (Input.GetKeyDown(KeyCode.Alpha1))        //Create a command pod!
        {
            ChatScript.ChatLocally("Detected local createObj order: Command Pod");
            //Send the order to the server
            hl.hlObj.CmdCreateObj(hl.local_uId, mousePos, (int)ObjFuncs.Type.CommandPod);

            //Trigger local effect
            //Effects.CircleBlip(mousePos, 5, 5);
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))        //Create a hull block
        {
            ChatScript.ChatLocally("Detected local createObj order: Hull Block");
            //Send the order to the server
            hl.hlObj.CmdCreateObj(hl.local_uId, mousePos, (int)ObjFuncs.Type.HullBlock);

            //Trigger local effect
            //Effects.CircleBlip(mousePos, 5, 5);
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))        //Create an engine
        {
            ChatScript.ChatLocally("Detected local createObj order: Engine");
            //Send the order to the server
            hl.hlObj.CmdCreateObj(hl.local_uId, mousePos, (int)ObjFuncs.Type.Engine);

            //Trigger local effect
            //Effects.CircleBlip(mousePos, 5, 5);
        }
        if (Input.GetKeyDown(KeyCode.Alpha4))        //Create a gun
        {
            ChatScript.ChatLocally("Detected local createObj order: Gun");
            //Send the order to the server
            hl.hlObj.CmdCreateObj(hl.local_uId, mousePos, (int)ObjFuncs.Type.Gun);

            //Trigger local effect
            //Effects.CircleBlip(mousePos, 5, 5);
        }
    }