Пример #1
0
    /// <summary>
    /// Changes the game's state.
    /// Essentially transitions the screen from one to another one (intro to menu, etc...)
    /// </summary>
    /// <param name="st"></param>
    public void ChangeState(GameStates st)
    {
        Sounder s = Sounder.Instance();

        switch (gameState)
        {
        case GameStates.Prepare:
            s.musicA.Stop();
            break;

        case GameStates.Game:
            s.musicA.Stop();



            Director d = Director.Instance();
            d.Release();


            // ??? <-- It sorta defeats the purpose of making all of those object pools if I just delete them like this...
            RemoveAllThings();
            break;
        }
        //
        if (gameStateMap.ContainsKey(gameState))
        {
            gameStateMap[gameState].SetActive(false);
        }
        //
        gameState = st;
        stateTime = 0;
        //
        ChangeModeState(GameStateModes.Beginning);
        //
        if (gameStateMap.ContainsKey(gameState))
        {
            gameStateMap[gameState].SetActive(true);
        }
        //
        switch (gameState)
        {
        case GameStates.Prepare:
            s.PlayMusic("jazzy");

            Designer de = Designer.Instance();
            de.SetupScreen(Database.Instance().QueryLevelInfo("Level 1"));     // ??? <-- BAD.
            break;

        case GameStates.Game:
            s.PlayMusic("emphasis");



            GameObject go;
            go = new GameObject("Director");
            go.transform.parent = this.transform;
            go.AddComponent <Director>();
            break;
        }
    }
Пример #2
0
 void Start()
 {
     //Don't add sounder to every object that needs it
     //Better attach it to some kind of GameManager and do Events
     mic    = GetComponent <Sounder>();
     sprite = GetComponent <SpriteRenderer>();
     state  = States.micNotRecording;
 }
Пример #3
0
        public static Sounder GetSounder()
        {
            if (sounder == null)
            {
                sounder = new Sounder();
            }

            return(sounder);
        }
Пример #4
0
 void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
         return;
     }
     instance = this;
     DontDestroyOnLoad(gameObject);
 }
Пример #5
0
    public override void OnSpawn(Actor by = null)
    {
        base.OnSpawn(by);
        //
        tr.Clear();
        power       = 10.0f;
        existPeriod = 2.5f * Helper.SECOND;

        Sounder.Instance().PlaySound("pellet_shoot");
    }
Пример #6
0
        public SounderGump(Mobile owner, Sounder device, int[] sounds) : base(25, 25)
        {
            owner.CloseGump(typeof(SounderGump));

            Closable   = true;
            Disposable = true;
            Dragable   = true;
            Resizable  = false;

            m_Owner   = owner;
            m_Sounder = device;

            int[] g_Sounds = new int[10];
            g_Sounds = sounds;

            string str;

            AddPage(0);

            AddBackground(0, 0, 200, 320, 0x13BE);

            AddImageTiled(46, 28, 108, 230, 0x98D);

            AddLabel(50, 292, 0, "Cancel");
            AddButton(18, 290, 0xFB1, 0xFB3, 0, GumpButtonType.Reply, 0);

            AddLabel(136, 292, 0, "Accept");
            AddButton(104, 290, 0xFB7, 0xFB9, 1, GumpButtonType.Reply, 0);

            AddLabel(50, 267, 0, "Props");
            AddButton(18, 265, 0xFAB, 0xFAD, 2, GumpButtonType.Reply, 0);

            AddLabel(136, 267, 0, "Sort");
            AddButton(104, 265, 0xFA8, 0xFAA, 3, GumpButtonType.Reply, 0);

            AddLabel(12, 6, 0, "Del");
            AddLabel(65, 6, 0, "Sound List");
            AddLabel(160, 6, 0, "Play");

            for (int i = 0; i < 10; i++)
            {
                if (g_Sounds[i] >= 0)
                {
                    str = g_Sounds[i].ToString();
                }
                else
                {
                    str = null;
                }

                AddButton(9, (23 * i) + 30, 0xFB4, 0xFB6, 10 + i, GumpButtonType.Reply, 0);
                AddTextEntry(54, (23 * i) + 30, 80, 19, 0, i, str);
                AddButton(160, (23 * i) + 30, 0xFAE, 0xFB0, 20 + i, GumpButtonType.Reply, 0);
            }
        }
Пример #7
0
    /// <summary>
    /// The core has a special counter-attack that triggers whenever it is attacked.
    /// This minimizes the deadliness of a "swarm" of creeps finding the core.
    /// However, this also means ONE creep is just about as deadly as ten,
    /// since the number of counter-attacks are relative to the amount of attackers.
    /// </summary>
    /// <param name="c"></param>
    public override void OnAttacked(Creep c)
    {
        base.OnAttacked(c);
        //
        Director    d  = Director.Instance();
        EnergyBurst eb = d.CreateDamageArea <EnergyBurst>(Helper.DEADZONE);

        eb.pos = pos;
        eb.OnSpawn();
        // *** This does not get an object pool because there can be ANY number of creeps hitting a core-- And they won't all necessarily be hitting it at once.

        Sounder.Instance().PlaySound("core_damage");
    }
Пример #8
0
    void Init()
    {
        state = States.NotInitialized;

        mic         = GetComponent <Sounder>();
        eventSystem = GetComponent <IgorEventSystemS>();

        _newSound = true;

        audioSource = GetComponent <AudioSource>();
        audioSource.Play();
        if (!audioSource.isPlaying)
        {
            Debug.Log("Not playing");
        }
        audioSource             = gameObject.AddComponent <AudioSource>();
        audioSource.playOnAwake = false;
        audioSource.loop        = false;
        audioSource.volume      = 0.5f;

        string[] controllers = Input.GetJoystickNames();
        if (controllers.Length > 0)
        {
            playerControl = new Pad();
            Debug.Log("Pad connected!");
        }
        else
        {
            playerControl = new Keyboard();
            Debug.Log("Keybard Connected");
        }

        lastTimePlayedDroplets = 0f;
        player = GameObject.Find("Player").GetComponent <Player>();
        points = 0;
        Text[] tempTab = GetComponentsInChildren <Text>();
        foreach (Text t in tempTab)
        {
            if (t.gameObject.name == "Score")
            {
                pointsText = t;
            }
        }
        pointsText.text = "0";
        endScreen       = GetComponentInChildren <EndScreen>();
        endScreen.gameObject.SetActive(false);
        state = States.GameInitialized;
    }
Пример #9
0
        private void SounderPanel_Paint(object sender, PaintEventArgs e)
        {
            var g = e.Graphics;

            try {
                float drawX = 0;
                for (var i = 0; i < CurLVL.Height - 1; i++)
                {
                    var drawX2 = drawX + (Sounderwidth / (CurLVL.Height - 1));
                    g.DrawLine(new Pen(Color.White, 2), drawX, Convert.ToSingle(CurLVL.DeepArray[Sounder.GetSounder().Row, i].Text) / 10, drawX2,
                               Convert.ToSingle(CurLVL.DeepArray[Sounder.GetSounder().Row, i + 1].Text) / 10);
                    drawX = drawX2;
                }
                DrawPoint(g);
            }
            catch (NullReferenceException) { }
        }
Пример #10
0
    // Use this for initialization
    void Start()
    {
        if (instance == null && this != instance)
        {
            instance = this;
        }
        else
        {
            Destroy(this.gameObject);
            return;
        }
        //
        DontDestroyOnLoad(this.gameObject);


        Initialize();
    }
Пример #11
0
 private void SetSounderCord(Point point)
 {
     for (var y = 0; y < CurLvl.Height; y++)
     {
         for (var x = 0; x < CurLvl.Widgth; x++)
         {
             var r = new Rectangle(CurLvl.DeepArray[x, y].Location, new System.Drawing.Size(40, 23));
             if (!r.IntersectsWith(new Rectangle(point, new System.Drawing.Size(1, 1))))
             {
                 continue;
             }
             Sounder.GetSounder().Column = y;
             Sounder.GetSounder().Row    = x;
             _player.EquipedRoad.CurrentDeep = Convert.ToInt32(CurLvl.DeepArray[x, y].Text);
             gui.LureDeepValue = _player.EquipedRoad.CurrentDeep;
         }
     }
 }
Пример #12
0
        private void DrawPoint(Graphics g)
        {
            var   player = Player.GetPlayer();
            float coef   = 0;
            var   height = 23 * CurLVL.Height;

            if (height >= Sounderwidth)
            {
                coef = Sounderwidth / height;
            }
            if (height < Sounderwidth)
            {
                coef = height / Sounderwidth;
            }
            float x = Sounder.GetSounder().Column *(Sounderwidth / CurLVL.Height);

            g.DrawEllipse(new Pen(Color.Black), x, Player.GetPlayer().EquipedRoad.CurrentDeep / 10 - 4, 4, 4);
        }
Пример #13
0
    public void ChangeMusic(Sounder sound)
    {
        targetSound = sound;
        if (targetSound != currentSound)
        {
            while (currentSound.source.volume > 0.1f)
            {
                currentSound.source.volume = Mathf.Lerp(currentSound.source.volume, 0, Time.deltaTime);
                targetSound.source.volume  = Mathf.Lerp(targetSound.source.volume, targetSound.targetVolume, Time.deltaTime);
            }
            currentSound.source.volume = 0;

            targetSound.source.enabled = false;
            targetSound.source.enabled = true;
            targetSound.source.volume  = targetSound.targetVolume;

            currentSound = targetSound;
        }
    }
Пример #14
0
    // Use this for initialization
    void Start()
    {
        _instance = this;

        for (int i = 0; i < sounders.Length; i++)
        {
            sounders[i].source             = gameObject.AddComponent <AudioSource>();
            sounders[i].source.clip        = sounders[i].song;
            sounders[i].source.playOnAwake = true;
            sounders[i].source.loop        = true;
            sounders[i].source.volume      = 0;
        }

        currentSound = sounders[0];
        targetSound  = sounders[0];

        ChangeMusic(sounders[0]);

        currentSound.source.enabled = false;
        currentSound.source.enabled = true;

        currentSound.source.volume = currentSound.targetVolume;
    }
Пример #15
0
    void Start()
    {
        GameManager.eventSystem.Subscribe("GameInitialized", StartGenerating);
        GameManager.eventSystem.Subscribe("PlayerDied", StopGenerating);
        MAP_WIDTH = (Camera.main.ScreenToWorldPoint(new Vector3(Camera.main.pixelWidth, 0, 5)) - Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 5))).x + MAP_WIDTH_APPEND;

        SAMPLING     = (int)((MAP_WIDTH * 2) / DISTANCE);
        lowerOffset  = new Vector3(0, MAP_BEGINNING_Y, 0);
        upperOffset  = new Vector3(0, MAP_END_Y, 0);
        depperOffset = new Vector3(0, 0, MAP_DEPTH);

        ceilingObject   = transform.FindChild("Ceiling").gameObject;
        floorObject     = transform.FindChild("Floor").gameObject;
        narrowingObject = transform.FindChild("Narrowing").gameObject;

        MAP_HEIGHT             = ceilingObject.transform.position.y - floorObject.transform.position.y;
        firstToMiddleLowOffset = depperOffset + new Vector3(0, (MAP_HEIGHT - NARROWING_HEIGHT) / 2, NARROWING_DEPTH);
        firstToMiddleUpOffset  = depperOffset + new Vector3(0, (MAP_HEIGHT + NARROWING_HEIGHT) / 2, NARROWING_DEPTH);
        firstToUpOffset        = depperOffset + new Vector3(0, MAP_HEIGHT, 0);

        spawner = gameObject.GetComponentInChildren <ObstacleSpawner>();

        array = GenerateSinToArray(SAMPLING, 12, phasa);
        Debug.Log("sampling");
        Debug.Log(SAMPLING);
        Debug.Log(array.Length);
        phasa  += 12;
        sounder = GameManager.mic;

        textureWidth = 10;

        CreateVerticesFromArray(array);
        UpdateFloorMesh();
        UpdateCeilingMesh();
        UpdateNarrowingMesh();
    }
Пример #16
0
 public SounderGump(Mobile owner, Sounder device) : this(owner, device, device.Sounds)
 {
 }
Пример #17
0
 public override void OnMiss(Obstruction c)
 {
     base.OnMiss(c);
     //
     Sounder.Instance().PlaySound("pellet_hit_wall");
 }
Пример #18
0
 public override void OnHit(Creep c)
 {
     base.OnHit(c);
     //
     Sounder.Instance().PlaySound("pellet_hit_creep");
 }