Ejemplo n.º 1
0
 public override void FixedUpdate()
 {
     if (moving)
     {
         if (velocity < NPCSpeed)
         {
             velocity += .01f;
         }
         else
         {
             velocity = NPCSpeed;
         }
     }
     else
     {
         velocity = 0;
     }
     if (animator == null)
     {
         animator = GO.GetComponent <Animator>() as Animator;
     }
     else
     {
         animator.SetFloat("runSpeed", velocity);
     }
 }
Ejemplo n.º 2
0
    public static List <T> FindAllPrefabInstancesWithType <T>(UnityEngine.Object myPrefab)
    {
        List <T> result = new List <T>();

        GameObject[] allObjects = (GameObject[])Resources.FindObjectsOfTypeAll(typeof(GameObject));
        foreach (GameObject GO in allObjects)
        {
#if UNITY_EDITOR
            if (PrefabUtility.GetPrefabType(GO) == PrefabType.PrefabInstance)
            {
                if (CheckGameObjectIsParentObject(GO, (GameObject)myPrefab))
                {
                    if (GO.GetComponent <T>() != null)
                    {
                        result.Add(GO.transform.GetComponent <T>());
                    }
                }
            }
#endif
            if (Application.isPlaying && !Application.isEditor)
            {
                if (CheckGameObjectIsParentObject(GO, (GameObject)myPrefab))
                {
                    if (GO.GetComponent <T>() != null)
                    {
                        result.Add(GO.transform.GetComponent <T>());
                    }
                }
            }
        }
        return(result);
    }
Ejemplo n.º 3
0
        private void UndoSpawn()
        {
            Debug.Log("Easyspawner: Undo spawn action");

            if (spawnActions.Count <= 0)
            {
                return;
            }

            List <GameObject> spawnedGameObjects = spawnActions.Pop();

            Debug.Log("Easyspawner: Destroying " + spawnedGameObjects.Count + " objects");
            string objectName = "objects";

            foreach (GameObject GO in spawnedGameObjects)
            {
                if (GO != null)
                {
                    objectName = GO.name.Remove(GO.name.Length - 7);
                    ZNetView zNetV = GO.GetComponent <ZNetView>();
                    if (zNetV && zNetV.IsValid() && zNetV.IsOwner())
                    {
                        zNetV.Destroy();
                    }
                }
            }

            Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Undo spawn of " + spawnedGameObjects.Count + " " + objectName);
            Debug.Log("Easyspawner: Spawn undone");
        }
Ejemplo n.º 4
0
    public bool GenerateCube(GameObject GO)
    {
        MeshFilter CubeMeshFilter = null;

        if (!GO)
        {
            GO             = new GameObject();
            CubeMeshFilter = GO.AddComponent <MeshFilter>();
            CubeMesh       = CubeMeshFilter.mesh;
            MeshRenderer MyMeshRenderer = GO.AddComponent <MeshRenderer>();
            GO.transform.localScale = new Vector3(1, 1, 1);
        }
        else
        {
            CubeMeshFilter = GO.GetComponent <MeshFilter>();

            if (CubeMeshFilter)
            {
                CubeMesh = CubeMeshFilter.mesh;
            }
        }

        if (CubeMeshFilter && CubeMesh)
        {
            Cube_vertices  = new List <Vector3>();
            Cube_triangles = new List <int>();
            Cube_CreateCube(GO);
        }

        CustomMessage = "";
        return(true);
    }
Ejemplo n.º 5
0
    //-------------------------
    void OnDestroy()
    {
        --Coin.CoinCount;

        //Check remaining coins
        if (Coin.CoinCount <= 0)
        {
            //Game is won. Collected all coins
            //Destroy Timer and launch fireworks
            GameObject Timer = GameObject.Find("LevelTimer");
            Destroy(Timer);

            GameObject[] FireworkSystems = GameObject.FindGameObjectsWithTag("Fireworks");

            if (FireworkSystems.Length <= 0)
            {
                return;
            }

            foreach (GameObject GO in FireworkSystems)
            {
                GO.GetComponent <ParticleSystem>().Play();
            }
        }
    }
Ejemplo n.º 6
0
    public string polyCounter()
    {
        int polycount = 0;
        int thisPoly  = 0;

        foreach (GameObject GO in AllGO)
        {
            MeshFilter newMesh = null;

            if (GO.gameObject.activeSelf)
            {
                Renderer rend = GO.GetComponent <Renderer>();
                if (rend != null && rend.isVisible)
                {
                    newMesh = GO.GetComponent <MeshFilter>();
                }
            }

            if (newMesh != null)
            {
                thisPoly   = newMesh.mesh.triangles.Length / 3;
                polycount += thisPoly;
                Debug.Log(GO.name + " this = " + thisPoly + " |new count = " + polycount);
            }
        }
        return(polycount.ToString());
    }
Ejemplo n.º 7
0
 private void SortArrayByDate(string str)
 {
     if (sortField != str)
     {
         sortField = str;
         ClothesDetails details;
         //finds the index where each item of clothing needs to go
         foreach (GameObject GO in clothesList)
         {
             details = GO.GetComponent <ClothesDetails>();
             //if list empty just add the first item
             if (tempList.Count == 0)
             {
                 tempList.Add(GO);
             }
             //if at any point can't find a lesser item in temp then return and add to the end of the list
             else if (FindObjDatePosition(details, str) == -1)
             {
                 tempList.Add(GO);
             }
             //Found a position where found a lesser or equal item, inserts it and shifts the  list along 1
             else
             {
                 int i = FindObjDatePosition(details, str);
                 tempList.Insert(i, GO);
             }
         }
         clothesList = new List <GameObject>(tempList);
     }
 }
Ejemplo n.º 8
0
    void UpdateDuckMats(int colour)
    {
        Material mat = duckYellow;

        switch (colour)
        {
        case (0):
            mat = duckYellow;
            break;

        case (1):
            mat = duckBlue;
            break;

        case (2):
            mat = duckRed;
            break;

        default:

            break;
        }


        foreach (GameObject GO in colourChangeObjects)
        {
            GO.GetComponent <Renderer> ().material = mat;
        }
    }
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Update Labels
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    void UpdateLabels()
    {
        if (PlayerControlsInstance.m_uiPlayerScore != m_uiScore)
        {
            RunScorePopup();
            m_uiScore           = PlayerControlsInstance.m_uiPlayerScore;
            m_uiScoreCount.text = "Score:  " + m_uiScore.ToString();
        }

        if (m_fHealthPercentage != PlayerControlsInstance.m_fHealth && PlayerControlsInstance.m_fHealth > 0)
        {
            // Play Alarm if Low Health. Only Play Once
            if (PlayerControlsInstance.m_fHealth < 20f && m_fHealthPercentage >= 20f)
            {
                m_HealthAlarmSource.Play();
            }

            // Back to Full Health after Dying?
            if (PlayerControlsInstance.m_fHealth > 99.9f)
            {
                foreach (GameObject GO in m_HealthObjects)
                {
                    GO.GetComponent <Visuals>().Reset();
                    GO.GetComponent <Visuals>().m_eHealthVisState = Visuals.eHealthVis.FINE;
                }
            }

            m_uiHealthPercenatge.text = "Health: " + GetHealthColour() + ((int)m_fHealthPercentage).ToString() + "%";
        }
    }
Ejemplo n.º 10
0
        private GameObject GetClosestJoint(GameObject link)
        {
            GameObject closest = null;

            GameObject[] allObjects = FindObjectsOfType <GameObject>();

            foreach (GameObject GO in allObjects)
            {
                if (GO.GetComponent <ObjectJoint>() != null && GO.activeInHierarchy)
                {
                    if (closest == null)
                    {
                        closest = GO;
                    }
                    else
                    {
                        if (Vector3.Distance(link.transform.position, GO.transform.position) < Vector3.Distance(link.transform.position, closest.transform.position))
                        {
                            closest = GO;
                        }
                    }
                }
            }

            return(closest);
        }
Ejemplo n.º 11
0
        private GameObject GetClosestLink(GameObject joint)
        {
            GameObject closest = null;

            GameObject[] allObjects = FindObjectsOfType <GameObject>();
            foreach (GameObject GO in allObjects)
            {
                if (GO.GetComponent <RobotLink>() != null)
                {
                    if (closest == null)
                    {
                        closest = GO;
                    }
                    else
                    {
                        if (Vector3.Distance(joint.transform.position, GO.transform.position) < Vector3.Distance(joint.transform.position, closest.transform.position))
                        {
                            closest = GO;
                        }
                    }
                }
            }

            return(closest);
        }
Ejemplo n.º 12
0
    // Start is called before the first frame update
    void Start()
    {
        rb             = GetComponent <Rigidbody>();
        rbOriginalMass = rb.mass;
        col            = GetComponent <CapsuleCollider>();
        //GetComponent<LineRenderer>().enabled = false; // Hide "Scarf"
        currentSpeed = Speed;
        isAiming     = false;

        // Search for all existing moveable and grapple objects and put them in a dictionary
        GameObject[] foundMoveableObjects = GameObject.FindGameObjectsWithTag("Moveable");
        GameObject[] foundGrappleObjects  = GameObject.FindGameObjectsWithTag("Grapple");
        tkObjects = new Dictionary <GameObject, Material>();

        foreach (GameObject MO in foundMoveableObjects)
        {
            tkObjects.Add(MO, MO.GetComponent <MeshRenderer>().material);
        }
        foreach (GameObject GO in foundGrappleObjects)
        {
            tkObjects.Add(GO, GO.GetComponent <MeshRenderer>().material);
        }

        Crosshairs.enabled = false;
        Cursor.visible     = false;
        Cursor.lockState   = CursorLockMode.Confined;
        distanceGround     = GetComponent <CapsuleCollider>().bounds.extents.y;
        haveLetGoOfMouse   = true;
        GrappleSpeed       = 0.05f;
        stowedObject       = false;
        spawnPosition      = transform.position;
    }
Ejemplo n.º 13
0
    void SendDataToPlayers()
    {
        string dataToSend = "";

        foreach (GameObject[] GOarray in WallArray)
        {
            foreach (GameObject GO in GOarray)
            {
                WallScript ws = GO.GetComponent <WallScript>();
                int        r  = ws.getRow();
                int        c  = ws.getCol();
                dataToSend += r + "," + c + "," + ws.GetHeight() + "|";
            }

            dataToSend = dataToSend.Substring(0, dataToSend.Length - 1);
            //Debug.Log("Sending data: "+ dataToSend);
            networkView.RPC("setMaze", RPCMode.Others, dataToSend);
            dataToSend = "";

            //Had to send the data at the end of every Row, turns out
            //that 4080 something characters was the maximum string allowed
            //to be sent through RPC calls.
        }

        networkView.RPC("setMaze", RPCMode.Others, "DONE");
    }
Ejemplo n.º 14
0
    private void OnSpawn(bool isFruit)
    {
        float x = Random.Range(-8.2f, 8.2f);
        float y = -5f;
        float z = tempZ;

        tempZ -= 2;
        if (tempZ <= -10)
        {
            tempZ = 0;
        }

        int        index = Random.Range(0, fruits.Length);
        GameObject GO;

        if (isFruit)
        {
            GO = Instantiate(fruits[index], new Vector3(x, y, z), Quaternion.identity);
        }
        else
        {
            GO = Instantiate(boom, new Vector3(x, y, 0), Quaternion.identity);
        }

        Vector3 vel = new Vector3(-x * Random.Range(0.2f, 0.8f), -Physics.gravity.y * Random.Range(1, 1.4f), 0);

        rb          = GO.GetComponent <Rigidbody>();
        rb.velocity = vel;
    }
Ejemplo n.º 15
0
    private void Start()
    {
        int    i          = 0;
        string PlayerName = "Player" + PlayerID.ToString() + "_Unit";

        foreach (Transform k in transform)
        {
            GameObject GO;
            if (k.name == "UnitSlot")
            {
                GO = (GameObject)Instantiate(SlimePrefab, k.position, k.rotation);
                GO.GetComponent <SlimeBehaviour>().PlayerID = PlayerID;
                GO.GetComponent <SlimeBehaviour>().UnitID   = PlayerName + i.ToString();
                i++;
            }
            else
            {
                GO = (GameObject)Instantiate(Crystals[Random.Range(0, Crystals.Length)], k.position, k.rotation);
            }
            MyItems.Add(GO);
            GO.transform.parent     = k;
            GO.transform.localScale = Vector3.one;
        }

        foreach (Transform k in GameObject.Find("Plansza").transform)
        {
            if ((PlayerID == 1 && k.position.z < -2.0f) || (PlayerID != 1 && k.position.z > 2.0f))
            {
                MyNodes.Add(k.gameObject);
            }
        }

        OnEnable();
    }
Ejemplo n.º 16
0
        public override void Update(float time)
        {
            Vector2 velocity = Vector2.Zero;

            if (Input.GetKey(PressAction.DOWN, Keys.A))
            {
                velocity = new Vector2(-1, 0);
            }
            if (Input.GetKey(PressAction.DOWN, Keys.D))
            {
                velocity = new Vector2(+1, 0);
            }
            if (Input.GetKey(PressAction.DOWN, Keys.W))
            {
                velocity = new Vector2(0, -1);
            }
            if (Input.GetKey(PressAction.DOWN, Keys.S))
            {
                velocity = new Vector2(0, +1);
            }

            Camera.SetCameraTopLeft(GO.Pos - GO.Size / 2f - new Vector2(16, 9) / 2f);
            GO.Pos += velocity * time * speed;
            //shoot
            if (Input.GetKey(PressAction.PRESSED, Keys.Space))
            {
                GO.GetComponent <CShoot>().Shoot(dir, new Vector2(0.2f, 0.2f));
            }
        }
Ejemplo n.º 17
0
    public void merge(ItemSpot is1, ItemSpot is2)
    {
        var i1 = is1.item;
        var i2 = is2.item;

        foreach (GameObject GO in allItems)
        {
            Item i = GO.GetComponent <Item>();
            if ((i.child1Name == i1.name && i.child2Name == i2.name) || (i.child1Name == i2.name && i.child2Name == i1.name))
            {
                GameObject g = Instantiate(GO);//TODO: handle weird unity naming convention (Clone)

                g.GetComponent <MeshRenderer>().enabled = false;
                g.GetComponent <MeshCollider>().enabled = false;

                g.name = GO.name;

                Debug.Log("Succesfully created " + i.name + " from " + i1.name + " and " + i2.name + ". Returning");
                is2.fillItem(i);
                GameObject.FindObjectOfType <EQ>().refreshItemSpots(is1.item);
                is1.item = null;
                i.OnMerge.Invoke();

                return;
            }
        }
        Debug.Log("Items " + i1.name + " and " + i2.name + " don't make anything. Returning");
    }
Ejemplo n.º 18
0
    public void Organise()
    {
        CollectChildren();
        foreach (GameObject GO in Children)
        {
            if (GO.GetComponent <CellScript>() != null)
            {
                CellScript cs = GO.GetComponent <CellScript>();
                //makes sure a mesh filter is connected
                if (cs.meshF == null)
                {
                    cs.meshF = cs.transform.gameObject.GetComponent <MeshFilter>();
                }

                //Sets the mesh
                if (cs.is_L_road)
                {
                    cs.meshF.mesh = meshL;
                }
                else if (cs.is_T_road)
                {
                    cs.meshF.mesh = meshT;
                }
                else if (cs.is_X_road)
                {
                    cs.meshF.mesh = meshX;
                }
                else if (cs.is_Straight_road)
                {
                    cs.meshF.mesh = meshStraight;
                }
            }
        }
    }
Ejemplo n.º 19
0
 void OnChangeTurn()
 {
     foreach (GameObject GO in playersOnServer)
     {
         GO.GetComponent <PlayerBHV>().currentTurn = this.currentTurn;
     }
 }
Ejemplo n.º 20
0
    public void NetowrkSpawn(GameObject Prefab, Vector3 pos)
    {
        GameObject GO;

        GO = PhotonNetwork.Instantiate(Prefab.name, pos, Quaternion.identity);
        GO.GetComponent <PhotonView>().RequestOwnership();
    }
Ejemplo n.º 21
0
    public void SearchRack()
    {
        print("Searching: " + searchInput.text.ToUpper());
        searchField = searchInput.text.ToUpper();
        tempList    = new List <GameObject>();
        ClothesDetails details;

        foreach (GameObject GO in displayList)
        {
            details = GO.GetComponent <ClothesDetails>();
            if (details.getName().ToUpper().Contains(searchField) ||
                details.getPrice().ToString().ToUpper().Contains(searchField) ||
                details.getColour().ToUpper().Contains(searchField) ||
                details.day.ToUpper().Contains(searchField) ||
                details.month.ToUpper().Contains(searchField) ||
                details.year.ToUpper().Contains(searchField))
            {
                tempList.Add(GO);
            }
            else
            {
                string[] size = details.getSize();
                for (int i = 0; i < size.Length; i++)
                {
                    if (size[i].ToUpper().Contains(searchField) && tempList.Contains(GO) == false)
                    {
                        tempList.Add(GO);
                    }
                }
            }
        }
        displayList = tempList;
        UpdateRack();
    }
Ejemplo n.º 22
0
    void Update()
    {
        if (reload <= 0)
        {
            float z = Random.Range(5.0f, 15.0f);
            float x = Random.Range(-0.57735f * z, 0.57735f * z);
            float y = -0.57735f * z * screenRatio - 0.5f;

            GameObject GO;
            if (readyToUse.Count == 0)
            {
                GO = (GameObject)Instantiate(bubble, new Vector3(x, y, z), Quaternion.identity);
            }
            else
            {
                GO = readyToUse[0];
                GO.transform.position = new Vector3(x, y, z);
                GO.GetComponent <BubbleMovement>().enabled = true;
                readyToUse.RemoveAt(0);
            }
            float   r     = Random.Range(0.0f, 1.0f);
            float   g     = Random.Range(0.0f, 1.0f);
            float   b     = Random.Range(0.0f, 1.0f);
            Vector3 color = new Vector3(r, g, b);
            color.Normalize();
            color /= Mathf.Max(color.x, color.y, color.z);
            GO.GetComponent <Renderer>().material.color = new Color(color.x, color.y, color.z);
            reload = interval;
        }
        else
        {
            reload -= Time.deltaTime;
        }
    }
Ejemplo n.º 23
0
    public bool GenerateCylinder(GameObject GO)
    {
        if (!GO)
        {
            GO = new GameObject();
            Cylinder_MeshFilter = GO.AddComponent <MeshFilter>();
            Cylinder_Mesh       = Cylinder_MeshFilter.mesh;
            MeshRenderer MyMeshRenderer = GO.AddComponent <MeshRenderer>();
            //need to set the material up top
            MyMeshRenderer.material = planetMaterial;
            GO.transform.localScale = new Vector3(1, 1, 1);
        }
        else
        {
            Cylinder_MeshFilter = GO.GetComponent <MeshFilter>();

            if (Cylinder_MeshFilter)
            {
                Cylinder_Mesh = Cylinder_MeshFilter.mesh;
            }
        }

        if (Cylinder_MeshFilter && Cylinder_Mesh)
        {
            Cylinder_MakingVertices(1, iter, leng, 0.5f, 0.1f);
        }

        CustomMessage = "";
        return(true);
    }
Ejemplo n.º 24
0
        private void ProcessStimBuffer()
        {
            TargetTrackingManager TM;

            foreach (GameObject GO in registrants)
            {
                TM = GO.GetComponent <TargetTrackingManager>();
                foreach (Stimulus stim in stimBuffer)
                {
                    if (stim.m_type == Stimulus.StimulusTypes.AudioMovement)
                    {
                        float range = Mathf.Abs((stim.m_location - GO.transform.position).magnitude);
                        if (range < stim.m_Radius)// if the simulus is in range of the AI accept the stimulus
                        {
                            TM.AcceptFilteredStimulus(stim);
                        }
                    }
                    if (stim.m_type == Stimulus.StimulusTypes.VisualCanSee)
                    {
                        TM.AcceptFilteredStimulus(stim);// if the AI can see the enemy the accept the stimulus
                    }
                }
            }
            stimBuffer.Clear();// clear the stimulation list
        }
Ejemplo n.º 25
0
        private void Check(SearchMethod Mode = SearchMethod.Static)
        {
            if (LP != DaCamera.transform.position || LR != DaCamera.transform.rotation)
            {
                LP = DaCamera.transform.position; LR = DaCamera.transform.rotation;

                if (Mode == SearchMethod.Normal)
                {
                    Populate(ControlTag);
                }

                VisibleObjects = 0;
                foreach (GameObject GO in SFCO)
                {
                    Plane[] planes = GeometryUtility.CalculateFrustumPlanes(DaCamera);
                    OS = GeometryUtility.TestPlanesAABB(planes, GO.GetComponent <Renderer>().bounds);

                    VisibleObjects += OS ? 1 : 0;

                    if (GO.GetComponent <Renderer>().enabled != OS)
                    {
                        GO.GetComponent <Renderer>().enabled = OS;
                    }
                }
            }
        }
Ejemplo n.º 26
0
    void Awake()
    {
        FlowSpeed *= -1.0f;
        for (int i = 0; i < NumberOfObject; i++)
        {
            float      dx = Random.Range(-30.0f, 0.0f);
            GameObject GO;
            if (dx < -15.0f)
            {
                GO = (GameObject)Instantiate(ObiectList[Random.Range(0, ObiectList.Length)], new Vector3(dx, 0.0f, Random.Range(-30.0f - dx, 30.0f + dx)), Quaternion.Euler(Random.Range(-90.0f, 90.0f), Random.Range(-90.0f, 90.0f), Random.Range(-90.0f, 90.0f)));
            }
            else
            {
                GO = (GameObject)Instantiate(ObiectList[Random.Range(0, ObiectList.Length)], new Vector3(dx, 0.0f, Random.Range(dx, -dx)), Quaternion.Euler(Random.Range(-90.0f, 90.0f), Random.Range(-90.0f, 90.0f), Random.Range(-90.0f, 90.0f)));
            }
            ActiveObject.Add(GO);
            GO.GetComponent <FlowObject>().Translation = (GO.transform.position.normalized);
            GO.transform.parent = this.transform;
        }

        DistanceBetween = 18.0f / (NumberOfObject * 1.1213f);
        for (int i = 1; i < Mathf.CeilToInt(1.1213f * NumberOfObject) + 1; i++)
        {
            GameObject GO = (GameObject)Instantiate(ObiectList[Random.Range(0, ObiectList.Length)], new Vector3(-2.5f, i * DistanceBetween, Random.Range(-2.0f, 2.0f)), Quaternion.Euler(Random.Range(-90.0f, 90.0f), Random.Range(-90.0f, 90.0f), Random.Range(-90.0f, 90.0f)));
            ActiveObject.Add(GO);
            GO.GetComponent <FlowObject>().Translation = new Vector3(0.0f, FlowSpeed, 0.0f);
            GO.transform.parent = this.transform;
        }
    }
Ejemplo n.º 27
0
    //-------------------------
    void OnDestroy()
    {
        --Coin.CoinCount;

        //Check remaining coins
        if (Coin.CoinCount <= 0)
        {
            Debug.Log("kolikot kerätty");
            SuccessText.enabled = true;
            //Game is won. Collected all coins
            //Destroy Timer and launch fireworks
            GameObject Timer = GameObject.Find("TimerScreen");
            Destroy(Timer);

            Instantiate(FireWorks, transform.position, Quaternion.Euler(-90, 0, 0));

            GameObject[] FireworkSystems = GameObject.FindGameObjectsWithTag("Fireworks");

            if (FireworkSystems.Length <= 0)
            {
                return;
            }

            foreach (GameObject GO in FireworkSystems)
            {
                GO.GetComponent <ParticleSystem>().Play();
            }
        }
    }
Ejemplo n.º 28
0
 void restartLevel()
 {
     foreach (GameObject GO in Resources.FindObjectsOfTypeAll(typeof(GameObject)))
     {
         if (GO.tag == "floor")
         {
             GO.SetActive(GO.GetComponent <floorTileScript>().activeAtStart);
         }
     }
     foreach (GameObject button in GameObject.FindGameObjectsWithTag("button"))
     {
         foreach (GameObject feature in button.GetComponent <buttonScript>().connectedFeatures)
         {
             if (feature.gameObject.tag == "floor")
             {
                 feature.SetActive(feature.GetComponent <floorTileScript> ().activeAtStart);
             }
             else
             {
                 feature.SetActive(feature.GetComponent <pressurePlate> ().activeAtStart);
             }
         }
     }
     transform.position = spawnPoint.transform.position;
 }
Ejemplo n.º 29
0
    void nextSwingInit()
    {
        gravityTriggers = GameObject.FindGameObjectsWithTag("gravityTrigger");
        //flip custom gravity zones & switches back to initial state
        foreach (GameObject GO in gravityTriggers)
        {
            GO.GetComponent <flipGravScript>().flip(GO.GetComponent <flipGravScript>().previousPosition);
        }

        /*//find what the f**k an up is
         * if (inCustomGravity)
         * {
         *  qTo = Quaternion.LookRotation(SwingVector, -CustomGravityVector);
         * }
         * else
         * {
         *  if (FindClosestGravityObject() != null)
         *  {
         *      qTo = Quaternion.LookRotation(SwingVector, (transform.position - FindClosestGravityObject().transform.position));
         *  }
         * }
         * //face.. forward
         * transform.rotation = qTo;
         * //move that way
         * transform.position += transform.up.normalized * 0.01f;*/
        mode = "start";
    }
Ejemplo n.º 30
0
    float CostEstimater(GameObject[] inputs, float count)
    {
        float estimatedCost = 0;
        int   ctr           = 0;

        foreach (GameObject item in inputs)
        {
            if (item.GetComponent <RawMaterial>())
            {
                estimatedCost += item.GetComponent <RawMaterial>().Price *count;
            }
            else
            {
                GameObject[] inputsOfMaterial = item.GetComponent <MealMaterial>().Inputs;
                float        inputCnt         = item.GetComponent <MealMaterial>().InputCount[ctr];
                foreach (GameObject GO in inputsOfMaterial)
                {
                    if (GO.GetComponent <RawMaterial>())
                    {
                        estimatedCost += GO.GetComponent <RawMaterial>().Price *inputCnt *count;
                    }
                    else
                    {
                        GameObject[] inputsOfMaterialOFMaterial = GO.GetComponent <MealMaterial>().Inputs;
                        foreach (GameObject GOO in inputsOfMaterialOFMaterial)
                        {
                            estimatedCost += CostEstimater(inputsOfMaterialOFMaterial, inputCnt);
                        }
                    }
                }
            }
            ctr++;
        }
        return(estimatedCost);
    }