예제 #1
0
파일: Bassin.cs 프로젝트: FrancoisPre/Koru
    private bool IsInsideMe(GameObject bassin, bool isBassin = true)
    {
        bool val = false;

        if (isBassin)
        {
            Bassin bassinScript = bassin.GetComponent <Bassin>();

            if (bassinScript != null && positionBassin.x + (bassinWidth / 2) >= bassin.transform.position.x + (bassinScript.bassinWidth / 2) && positionBassin.x - (bassinWidth / 2) <= bassin.transform.position.x - (bassinScript.bassinWidth / 2))
            {
                if (positionBassin.z + (bassinLenght / 2) >= bassin.transform.position.z + (bassinScript.bassinLenght / 2) && positionBassin.z - (bassinLenght / 2) <= bassin.transform.position.z - (bassinScript.bassinLenght / 2))
                {
                    val = true;
                }
            }
        }
        else
        {
            if (positionBassin.x + (bassinWidth / 2) > bassin.transform.position.x && positionBassin.x - (bassinWidth / 2) < bassin.transform.position.x)
            {
                if (positionBassin.z + (bassinLenght / 2) > bassin.transform.position.z && positionBassin.z - (bassinLenght / 2) < bassin.transform.position.z)
                {
                    val = true;
                }
            }
        }
        return(val);
    }
예제 #2
0
파일: Bassin.cs 프로젝트: FrancoisPre/Koru
    public void ResetToSavedWaterLevel()
    {
        overFlow = 0;
        childs   = new List <Bassin>();

        foreach (GameObject bassin in GameObject.FindGameObjectsWithTag("Bassin"))
        {
            if (bassin != gameObject && IsInsideMe(bassin))
            {
                Bassin bassinComponen = bassin.GetComponent <Bassin>();
                childs.Add(bassinComponen);
            }
        }

        WaterLevel = initialLevel;
        Water.transform.position = new Vector3(positionBassin.x, (Edge - Deept) + WaterLevel, positionBassin.z);

        if (isRootBassin)
        {
            foreach (Bassin child in childs)
            {
                child.ResetToSavedWaterLevel();
            }
        }
    }
예제 #3
0
    // Use this for initialization
    void Start()
    {
        int i = 0;

        foreach (GameObject element in levelref)
        {
            element.GetComponentInChildren <Goal>().SetlevelId(i);
            element.GetComponentInChildren <Goal>().SetSinglePlayer(singlePlayerMode);
            element.GetComponentInChildren <StartPoint>().SetlevelId(i);
            element.GetComponentInChildren <Faucet>().onOff = false;
            i++;
        }
        for (int forint = 1; forint < levelref.Count; forint++)
        {
            levelref[forint].SetActive(false);
            levelref[forint].transform.position -= new Vector3(0, sinkValue, 0);
        }
        goalref        = levelref[0].transform.FindChild("Goal").gameObject;
        targetPos      = levelref[currentLevel].transform.position;
        camref         = FindObjectOfType <CameraManager>();
        ocean          = GameObject.FindGameObjectWithTag("OceanRef").GetComponentInParent <Bassin>();
        objectSpawners = levelref[currentLevel].GetComponentsInChildren <ObjectSpawner>();
        foreach (ObjectSpawner element in objectSpawners)
        {
            element.transform.position += new Vector3(0, sinkValue, 0);
            RaycastHit hit;
            Physics.Raycast(element.gameObject.transform.position, Vector3.down, out hit, Mathf.Infinity, 1 << 0);
            //Debug.Log(hit.transform.tag);
            element.transform.position = new Vector3(element.transform.position.x, hit.transform.position.y + 1, element.transform.position.z);
            element.Spawn();
        }
    }
예제 #4
0
파일: Faucet.cs 프로젝트: FrancoisPre/Koru
    public static void spawnWater(Vector3 _position, float volume, bool isOverflow = false)
    {
        float quality = _overflowQuality;

        if (!isOverflow)
        {
            quality = _sourceQuality;
        }
        Bassin ocean = GameObject.FindGameObjectWithTag("OceanRef").GetComponentInParent <Bassin>();

        volume /= quality;
        for (int i = 0; i < quality; i++)
        {
            if (waterPool.Count == 0)
            {
                GameObject water = (GameObject)Resources.Load("Water");
                waterPool.Add((GameObject)Instantiate(water, new Vector3(-100 - (waterPool.Count / 100), 100 + (waterPool.Count % 100), -100), Quaternion.identity));
            }
            GameObject waterObject = waterPool[0];
            waterPool.Remove(waterObject);

            waterObject.transform.position = _position + i * new Vector3(0.02f, 0, 0.02f);

            if (ocean.getWaterLevelAtMyLocation(waterObject) > waterObject.transform.position.y)
            {
                waterObject.transform.position += new Vector3(0, (ocean.getWaterLevelAtMyLocation(waterObject) - waterObject.transform.position.y) + 2.0f, 0);
            }
            waterObject.GetComponent <Rigidbody>().isKinematic = false;
            //waterObject.SetActive(true);

            waterObject.GetComponent <WaterBehaviour>().volume = volume;
            float rayon = Mathf.Pow((volume * 3) / (4 * Mathf.PI), (1 / 3.0f));
            waterObject.transform.localScale = new Vector3(rayon / 2, rayon / 2, rayon / 2);
        }
    }
예제 #5
0
 public MainWindow()
 {
     _sensorData = new List <SensorData>();
     _bassin     = new Bassin();
     if (ConnectionManagerSingleton.Instance.ConnectToServer() == false)
     {
         MessageBox.Show("Could not connect to socket server");
     }
     InitializeComponent();
 }
예제 #6
0
 public Player(float playersMaxSoundRange, float playersFireRate, float playersAngleMax, float playersMaxRange)
 {
     maxSoundRange = playersMaxSoundRange;
     fireRate      = playersFireRate;
     angleMax      = playersAngleMax;
     MaxRange      = playersMaxRange;
     GameManager.Instance.GetComponent <AudioManager>().SetgameOverSoundPlay(false);
     GameManager.Instance.gameOver = false;
     ocean = GameObject.FindGameObjectWithTag("OceanRef").GetComponentInParent <Bassin>();
 }
예제 #7
0
파일: Bassin.cs 프로젝트: FrancoisPre/Koru
 public void updateNewLevelBassins()
 {
     if (!isRootBassin)
     {
         this.transform.position = new Vector3(this.transform.position.x, (this.transform.position.y - this.transform.parent.transform.position.y) + this.transform.parent.transform.position.y, this.transform.position.z);
         Edge = (this.transform.parent.transform.position.y + (this.transform.position.y - this.transform.parent.transform.position.y)) + baseEdge;
     }
     else
     {
         SaveCurentWaterLevel();
     }
     foreach (GameObject bassin in GameObject.FindGameObjectsWithTag("Bassin"))
     {
         if (bassin != gameObject && IsInsideMe(bassin))
         {
             Bassin bassinComponen = bassin.GetComponent <Bassin>();
             childs.Add(bassinComponen);
             bassinComponen.updateNewLevelBassins();
         }
     }
 }
예제 #8
0
파일: Bassin.cs 프로젝트: FrancoisPre/Koru
    // Use this for initialization
    void Start()
    {
        baseEdge = Edge;
        mesh     = new Mesh();
        if (!isRootBassin)
        {
            SaveCurentWaterLevel();
        }
        Corners = this.transform.GetChild(0).gameObject;
        Walls   = this.transform.GetChild(1).gameObject;
        Bottom  = this.transform.GetChild(2).gameObject;
        Water   = this.transform.GetChild(3).gameObject;

        positionBassin = this.transform.position;
        float height = (Edge - positionBassin.y);

        if (!isLocked)
        {
            if (displayWalls)
            {
                Corners.transform.GetChild(0).position = new Vector3((-bassinWidth) / 2, height / 2, (-bassinLenght) / 2) + positionBassin;
                Corners.transform.GetChild(1).position = new Vector3((bassinWidth) / 2, height / 2, (-bassinLenght) / 2) + positionBassin;
                Corners.transform.GetChild(2).position = new Vector3((-bassinWidth) / 2, height / 2, (bassinLenght) / 2) + positionBassin;
                Corners.transform.GetChild(3).position = new Vector3((bassinWidth) / 2, height / 2, (bassinLenght) / 2) + positionBassin;


                Walls.transform.GetChild(0).position = new Vector3(0, height / 2, ((-bassinLenght) / 2) - wallsOffset) + positionBassin;
                Walls.transform.GetChild(1).position = new Vector3(0, height / 2, ((bassinLenght) / 2) + wallsOffset) + positionBassin;
                Walls.transform.GetChild(2).position = new Vector3(((-bassinWidth) / 2) - wallsOffset, height / 2, 0) + positionBassin;
                Walls.transform.GetChild(3).position = new Vector3(((bassinWidth) / 2) + wallsOffset, height / 2, 0) + positionBassin;


                Vector3 scaleModifierCorner = new Vector3(cornersScale, height, cornersScale);
                for (int i = 0; i < Corners.transform.childCount; i++)
                {
                    Corners.transform.GetChild(i).localScale = scaleModifierCorner;
                }

                Walls.transform.GetChild(0).localScale = new Vector3(bassinWidth, height, wallsScale);
                Walls.transform.GetChild(1).localScale = new Vector3(bassinWidth, height, wallsScale);
                Walls.transform.GetChild(2).localScale = new Vector3(wallsScale, height, bassinLenght);
                Walls.transform.GetChild(3).localScale = new Vector3(wallsScale, height, bassinLenght);
            }
            else
            {
                Walls.SetActive(false);
            }
            Bottom.transform.position   = new Vector3(positionBassin.x, Edge - Deept, positionBassin.z);
            Bottom.transform.localScale = new Vector3(bassinWidth, 1, bassinLenght);

            Water.transform.position = new Vector3(positionBassin.x, (Edge - Deept) + WaterLevel, positionBassin.z);
            if (!isRootBassin)
            {
                this.GetComponent <BoxCollider>().size   = new Vector3(bassinWidth, 1, bassinLenght);
                this.GetComponent <BoxCollider>().center = new Vector3(0, Edge - 0.7f, 0);
            }
            else
            {
                this.GetComponent <BoxCollider>().size   = new Vector3(bassinWidth, 5, bassinLenght);
                this.GetComponent <BoxCollider>().center = new Vector3(0, (Edge - Deept + WaterLevel - 1.5f) - positionBassin.y, 0);
            }
        }
        // Water.transform.localScale = new Vector3(bassinWidth / 10, 1, bassinLenght / 10);



        childs = new List <Bassin>();
        foreach (GameObject bassin in GameObject.FindGameObjectsWithTag("Bassin"))
        {
            if (bassin != gameObject && IsInsideMe(bassin))
            {
                Bassin bassinComponen = bassin.GetComponent <Bassin>();
                childs.Add(bassinComponen);
            }
        }

        volume = bassinWidth * bassinLenght * volumeModifier;
        if (isRootBassin)
        {
            transform.FindChild("Bottom").tag = "OceanRef";
            volume /= rootModifier * 100000;
        }



        tri      = new List <int>();
        vertices = new List <Vector3>();

        vertices.Add(new Vector3(-bassinWidth / 2, 0, -bassinLenght / 2));
        vertices.Add(new Vector3(bassinWidth / 2, 0, -bassinLenght / 2));
        vertices.Add(new Vector3(-bassinWidth / 2, 0, bassinLenght / 2));
        vertices.Add(new Vector3(bassinWidth / 2, 0, bassinLenght / 2));
        splitPlane(0, 1, 2, 3, 0);

        vertices.Add(new Vector3(-bassinWidth / 2, -colliderHeight, -bassinLenght / 2));
        vertices.Add(new Vector3(bassinWidth / 2, -colliderHeight, -bassinLenght / 2));
        vertices.Add(new Vector3(-bassinWidth / 2, -colliderHeight, bassinLenght / 2));
        vertices.Add(new Vector3(bassinWidth / 2, -colliderHeight, bassinLenght / 2));
        int verticesCount = vertices.Count;

        splitPlane(verticesCount - 4, verticesCount - 3, verticesCount - 2, verticesCount - 1, -colliderHeight);

        updatePlane();
    }
예제 #9
0
 // Use this for initialization
 void Start()
 {
     ocean = GameObject.FindGameObjectWithTag("OceanRef").GetComponentInParent <Bassin>();
 }