Beispiel #1
0
 public void playSound(AudioClip sound)
 {
     foreach (AudioSource AS in _audioSource)
     {
         if (!AS.isPlaying)
         {
             AS.PlayOneShot(sound);
             break;
         }
     }
 }
    //systeme déposer le cube lorsqu'on est dans une zone propice.

    void ActionDisponibleLacherCube()
    {
        //son
        if (PanelPressSpace.activeSelf == false && GameObject.Find("SmallItem1").GetComponent <Event1>().tutorialFinished == false)
        {
            PanelPressSpace.SetActive(true);
        }
        if (!playSoundOncePressE)
        {
            AudioSource AS;
            AS = GameObject.Find("Sound1").GetComponent <AudioSource> ();
            AS.PlayOneShot(PressESound);
            playSoundOncePressE = true;
        }
        //bouton "Press E" apparaitre a l'écran
    }
    //il faut que je check par rapport a la plus proche le chaud froid
    //il faut que je check globalement si une apparait a moins de 50m

    //Systeme chaud froid

    void ActiverChaudFroid()
    {
        if (!playSoundOnceHC)
        {
            AudioSource AS;
            AS = GameObject.Find("Sound1").GetComponent <AudioSource> ();
            AS.PlayOneShot(hotColdActivationSound);
            playSoundOnceHC = true;
        }


        QTSurfShad.scaleModifier = (distanceChaudFroid - DistanceLaPlusProche) / 4;
        QTSurfShad.speedModifier = (distanceChaudFroid - DistanceLaPlusProche) / 4;
        QTSurfShad.noiseStrength = (distanceChaudFroid - DistanceLaPlusProche) / distanceChaudFroid / 2;

        anim.speed = (distanceChaudFroid - DistanceLaPlusProche) / (distanceChaudFroid / 4);
    }
Beispiel #4
0
    public IEnumerator PlayOneShotAudio(int audioIndex)
    {
        GameObject  temp = new GameObject();
        AudioSource AS;

        Debug.Log(string.Format("Playing audio: {0}", fx_list[audioIndex]));

        temp.transform.parent = transform;
        temp.AddComponent <AudioSource>();
        AS      = temp.GetComponent <AudioSource>();
        AS.clip = fx_list[audioIndex];
        AS.PlayOneShot(AS.clip, 0.2f);
        Debug.Log(string.Format("Audio Still Playing? {0}", AS.isPlaying));

        while (AS.isPlaying)
        {
            yield return(null);
        }

        Destroy(temp);
        yield return(null);
    }
Beispiel #5
0
    public override void TurnUpdate()
    {
        //if path got, starts walking
        if (mc.path.Count > 0)
        {
            moveDestination = mapInfo[mc.path[0]].transform.position;
            moveDestination = new Vector3(moveDestination.x, moveDestination.y + 0.4f, moveDestination.z - 1.0f);
            //already move to the destination(next tile)
            if (transform.position == moveDestination && currentPos == mc.path[0])
            {
                mc.path.RemoveAt(0);
                //check if there is next tile to go to
                if (mc.path.Count > 0)
                {
                    //check if next tile is snow tile
                    if (mc.map_tiles[mc.path[0]].GetComponent <Tile>().tile_type == "Snow")
                    {
                        Debug.Log("Splippery!!!!!!!!!!!!!!!");
                        int next_tile     = mc.path[0];
                        int offset        = mc.path[0] - currentPos;
                        int slippery_tile = next_tile + offset;
                        mc.path = new List <int>();
                        mc.path.Add(next_tile);
                        //no unit on slippery tile
                        if (mc.units_state[slippery_tile] == null)
                        {
                            int next_tile_x     = next_tile % mc.map_size;
                            int next_tile_y     = next_tile / mc.map_size;
                            int slippery_tile_x = slippery_tile % mc.map_size;
                            int slippery_tile_y = slippery_tile / mc.map_size;
                            if (Mathf.Abs(next_tile_x - slippery_tile_x) <= 1 &&
                                Mathf.Abs(next_tile_y - slippery_tile_y) <= 1)
                            {
                                slippery = true;
                                mc.path.Add(slippery_tile);
                            }
                        }
                    }
                    //check if next tile is muddy tile
                    else if (mc.map_tiles[mc.path[0]].GetComponent <Tile>().tile_type == "Muddy")
                    {
                        Debug.Log("Muddy!!!!!!!!!!!!!!!");
                        int next_tile = mc.path[0];
                        mc.path = new List <int>();
                        mc.path.Add(next_tile);
                    }
                    //check if next tile is on fire
                    //if (mc.map_tiles[mc.path[0]].GetComponent<Tile>().on_fire)
                    //on_fire = true;

                    //if next tile is snow, increase movespeed
                    if (slippery && mc.path.Count <= 1)
                    {
                        moveSpeed += 3;
                    }

                    mc.units_state[currentPos] = null;
                    currentPos = mc.path[0];
                    mc.units_state[currentPos] = gameObject;
                    moveDestination            = mapInfo[mc.path[0]].transform.position;
                    moveDestination            = new Vector3(moveDestination.x, moveDestination.y + 0.7f, moveDestination.z - 1.0f);
                    mc.character_moving        = true;
                }
                //AI finished moving, start attacking or picking the peach
                else
                {
                    //if moves to fire tile, change health
                    if (mc.map_tiles[currentPos].GetComponent <Tile>().on_fire)
                    {
                        Health_Change(fire_damage);
                        on_fire = true;
                    }

                    //if moves to trap tile, change health
                    if (mc.map_tiles[currentPos].GetComponent <Tile>().trap)
                    {
                        Health_Change(trap_damage);
                        mc.map_tiles[currentPos].GetComponent <Tile>().trap.GetComponent <trap>().triggered = true;
                    }

                    //attack first
                    if (!turnComplete)
                    {
                        foreach (int position in attackRange)
                        {
                            if (currentPos + position >= 0 && currentPos + position <= mc.map_size * mc.map_size - 1)
                            {
                                if (mc.units_state[currentPos + position] != null &&
                                    mc.units_state[currentPos + position].gameObject.name.StartsWith("Peach"))
                                {
                                    anim.Play("Attack");
                                    AS.PlayOneShot(Attack_Clip, 1.0f);
                                    Destroy(mc.units_state[currentPos + position].gameObject);
                                    mc.peach_count--;
                                    turnComplete = true;
                                    break;
                                }
                            }
                        }
                    }
                    //if didn't attack, check if can pick the peach
                    if (!turnComplete)
                    {
                        foreach (int position in pickRange)
                        {
                            if (currentPos + position >= 0 && currentPos + position <= mc.map_size * mc.map_size - 1)
                            {
                                if (mc.units_state[currentPos + position] != null && mc.units_state[currentPos + position].gameObject.CompareTag("Peach") &&
                                    !hasPeach)
                                {
                                    GameObject peach = mc.units_state[currentPos + position].gameObject;
                                    mc.peach_pos = currentPos;

                                    hasPeach     = true;
                                    turnComplete = true;
                                    mc.units_state[currentPos + position] = null;
                                    Destroy(peach);
                                    break;
                                }
                            }
                        }
                    }
                    acting = false;
                    mc.character_moving = false;
                    moveSpeed           = _moveSpeed;
                    slippery            = false;
                }
            }
        }
    }
    IEnumerator CheckEveryHalfSec()
    {
        yield return(new WaitForSeconds(0.5f));

        for (int i = 0; i < T.Length; i++)
        {
            distance [i] = Vector3.Distance(det [i].pos, Player.transform.position);
            //print (distance [i] + det[i].Name);

            //check si c'est a moins de distancePremierCercleDetection
            if (distance [i] < distancePremierCercleDetection)
            {
                if (!isDetectedAround.Contains(det [i]))
                {
                    isDetectedAround.Add(det [i]);
                    print("added smthg to array");
                    print(det [i].Name);

                    //det [i].isDetectedFarCircle = true;

                    //Envoyer au détectable spécifique le fait qu'il a été vu de loin

                    GameObject.Find(det[i].Name).GetComponent <DetectableLocalManager>().ImDetectedFar();
                    T[i].transform.GetChild(0).gameObject.SetActive(true);

                    //play sound
                    AudioSource AS;
                    AS = GameObject.Find("Sound1").GetComponent <AudioSource> ();
                    AS.PlayOneShot(LongueDistanceDetection);

                    //ajouter a la carte l'info comme quoi un nouvel objet est apparu
                    // faire briller l'icone de la map
                }
            }



            if (distance[i] <= distancePressE)
            {
                GameObject.Find(det[i].Name).GetComponent <DetectableLocalManager>().YouCanPressE();
            }

            if (distance[i] > distancePressE)
            {
                GameObject.Find(det[i].Name).GetComponent <DetectableLocalManager>().ICantPressEAnyMore();
            }

            //check si c'est a moins de distancePremierCercleDetection
        }

        //calcul chaud froid par rapport a l'objet le plus proche
        DistanceLaPlusProche = (Mathf.Min(distance));
//		print (Array.IndexOf(distance, Mathf.Min(distance)));
        //print (DistanceLaPlusProche);

        //systeme de chaud froid

        if (DistanceLaPlusProche < distanceChaudFroid)
        {
            ActiverChaudFroid();
        }
        else
        {
            DesactiverChaudFroid();
        }

        //systeme lacher le cube

        if (DistanceLaPlusProche < distancePressE)
        {
            //global action comme le son
            ActionDisponibleLacherCube();
            //envoyer au local
        }
        else
        {
            DesactiverActionDisponibleLacherCube();
        }


        StartCoroutine("CheckEveryHalfSec");
    }