Inheritance: MonoBehaviour
Ejemplo n.º 1
0
 public override void Attack()
 {
     if (!m_IsPlaced)
     {
         return;
     }
     if (m_AttackDelay <= 0)
     {
         if (m_EnemyTarget != null)
         {
             if (!m_EnemyTarget.active || m_EnemyTarget.GetComponent <AI>().getHealth() <= 0)
             {
                 m_EnemyTarget = null;
                 return;
             }
             MusicHandler.PlaySound(SoundType.SPEAR_THROW);
             m_AttackDelay = DEFAULT_ATTACK_DELAY;
             float      angle = Mathf.Atan2(m_EnemyTarget.transform.position.y - transform.position.y, m_EnemyTarget.transform.position.x - transform.position.x);
             GameObject obj   = SpriteManage.CREATE_SPRITE(SpriteType.SPEAR);
             Debug.Assert(obj);
             obj.transform.position = transform.position;
             Spear spear = obj.GetComponent <Spear>();
             spear.Init(angle, ObjectSide.OUR_SIDE);
         }
         else
         {
             m_AttackDelay = 0;
         }
     }
 }
    // angle in radian
    public void throwSpear(float angle)
    {
        if (m_Health <= 0)
        {
            return;
        }
        if (m_currentWeapon != null)
        {
            if (m_weaponDelay > 0)
            {
                return;
            }
            if (m_currentWeapon.m_Quantity <= 0)
            {
                return;
            }
            if (m_currentWeapon.m_item == ItemType.SPEAR)
            {
                m_currentWeapon.m_Quantity--;
                m_Weapons.setQuantity(m_currentWeapon);

                GameObject temp  = SpriteManage.CREATE_SPRITE(SpriteType.SPEAR);
                Spear      spear = temp.GetComponent <Spear>();
                spear.transform.position = transform.position;
                spear.Init(angle, ObjectSide.OUR_SIDE);
                MusicHandler.PlaySound(SoundType.SPEAR_THROW);
                m_weaponDelay = AXE_DELAY;
                if (m_currentWeapon.m_Quantity <= 0)
                {
                    changeWeapon(0);
                }
            }
        }
    }
Ejemplo n.º 3
0
    void FixedUpdate()
    {
        Collider[] withinAggroColliders = Physics.OverlapSphere(transform.position, 10, aggroLayerMask);
        if (withinAggroColliders.Length > 0)
        {
            CancelInvoke("BackToInitialPosition");
            CancelInvoke("Heal");
            Collider collider = withinAggroColliders[0];
            MusicHandler.PlayWarMusic();

            ChasePlayer(collider.GetComponent <Player>());
        }
        else if (navMeshAgent.velocity.Equals(Vector3.zero) && Vector3.Distance(transform.position, initialPosition) > navMeshAgent.stoppingDistance)
        {
            if (!IsInvoking("BackToInitialPosition"))
            {
                Invoke("BackToInitialPosition", 5.0f);
            }
        }
        else if (Vector3.Distance(transform.position, initialPosition) <= navMeshAgent.stoppingDistance)
        {
            if (IsInvoking("BackToInitialPosition"))
            {
                CancelInvoke("BackToInitialPosition");
            }
        }
    }
Ejemplo n.º 4
0
    private void Awake()
    {
        // if the singleton hasn't been initialized yet
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }

        instance = this;
        DontDestroyOnLoad(this.gameObject);

        if (!PlayerPrefs.HasKey("MusicVolume"))
        {
            PlayerPrefs.SetFloat("MusicVolume", 1);
        }
        if (!PlayerPrefs.HasKey("SFXVolume"))
        {
            PlayerPrefs.SetFloat("SFXVolume", 1);
        }
        if (!PlayerPrefs.HasKey("Language"))
        {
            PlayerPrefs.SetInt("Language", 0);
        }

        language           = PlayerPrefs.GetInt("Language");
        musicSource.volume = PlayerPrefs.GetFloat("MusicVolume");
        SFXVolume          = PlayerPrefs.GetFloat("SFXVolume");
        playTutorial       = (PlayerPrefs.GetInt("PlayedTutorial") == 0);
    }
Ejemplo n.º 5
0
    public void AttackRock()
    {
        // set the selection square is show
        // if characters holding axe and clicked on  the tree in range, then tree health is -1
        if (m_Character.m_currentWeapon.m_item != ItemType.AXE)
        {
            return;
        }
        const float OFFSET   = 16;
        float       distance = Vector2.Distance(Camera.main.WorldToScreenPoint(m_Character.transform.position), Camera.main.WorldToScreenPoint(transform.position));

        MusicHandler.PlaySound(SoundType.AXE_SOUND);
        m_health--;
        Debug.Log("rock is attacked");
        if (m_health < 0)
        {
            gameObject.SetActive(false);
            Debug.Log("rock is destroyed");
            SpriteManage.DESTROY_SPRITE(gameObject);
            // generate tree log after tree is cut down
            for (int i = 0; i < NUMBER_OF_STONE; i++)

            {
                GameObject temp = SpriteManage.CREATE_SPRITE(SpriteType.STONE);
                Debug.Assert(temp);
                Vector2 newPos = SpriteManage.randomAroundPoint(transform.position, 16);
                temp.transform.position = newPos;
            }
        }
    }
Ejemplo n.º 6
0
    public void AttackTree()
    {
        if (m_Character.m_currentWeapon.m_item != ItemType.AXE)
        {
            return;
        }

        MusicHandler.PlaySound(SoundType.AXE_SOUND);
        m_health--;
        Debug.Log("tree is attacked");
        if (m_health < 0)
        {
            gameObject.SetActive(false);
            Debug.Log("Tree is destroyed");
            SpriteManage.DESTROY_SPRITE(gameObject);
            // generate tree log after tree is cut down
            for (int i = 0; i < NUMBER_OF_TREE_LOG; i++)

            {
                GameObject temp = SpriteManage.CREATE_SPRITE(SpriteType.TREE_LOG);
                Debug.Assert(temp);
                Vector2 newPos = SpriteManage.randomAroundPoint(transform.position, 16);
                temp.transform.position = newPos;
            }
        }
    }
Ejemplo n.º 7
0
    void GetInteraction()
    {
        Ray        interactionRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit interactionInfo;

        if (Physics.Raycast(interactionRay, out interactionInfo, Mathf.Infinity))
        {
            playerAgent.updateRotation = true;
            GameObject interactedObject = interactionInfo.collider.gameObject;
            if (interactedObject.tag == "Enemy")
            {
                CancelLastInteractable(interactedObject.GetComponent <Interactable>());
                playerWeaponController.OnTargetInteraction(playerAgent);
                interactedObject.GetComponent <Interactable>().MoveToInteraction(playerAgent);
                MusicHandler.PlayWarMusic();
            }
            else if (interactedObject.tag == "Interactable Object")
            {
                CancelLastInteractable(interactedObject.GetComponent <Interactable>());
                playerAgent.stoppingDistance = 2f;
                interactedObject.GetComponent <Interactable> ().MoveToInteraction(playerAgent);
            }
            else
            {
                CancelLastInteractable();
                playerAgent.stoppingDistance = 0;
                playerAgent.destination      = interactionInfo.point;
            }
        }
    }
    void Start()
    {
        musicHandler = GameHandler.musicHandler;

        loopLength = musicHandler.GetCurrentSequenceLength() * loopLengthMultiplier;

        SetState(State.FadeFromWhite);
    }
Ejemplo n.º 9
0
    void Awake()
    {
        instance = this;

        audioSource      = GetComponent <AudioSource>();
        audioSource.loop = true;
        audioSource.Stop(); // Stop if playOnAwake is on
    }
Ejemplo n.º 10
0
 public MusicPlayer(GuildHandler GuildHandler, MusicHandler MusicHandler)
 {
     this.GuildHandler = GuildHandler;
     this.MusicHandler = MusicHandler;
     audioClient       = null;
     currentSong       = null;
     mProcess          = null;
     volume            = 1.0f;
 }
Ejemplo n.º 11
0
	void Start () {
		UpdateUI();
		
		//bossPanelAnimator = BossPanel.GetComponent<Animator>();
		bossHPSlider = BossPanel.GetComponentInChildren<Slider>();
		canvasAnimator = canvas.GetComponent<Animator>();
		Time.timeScale = 0f;
		music = GetComponentInChildren<MusicHandler> ();
	}
Ejemplo n.º 12
0
 // Check if instance already exists and destroy if yes
 void Awake()
 {
     if (instance != null && instance != this) {
         Destroy(this.gameObject);
         return;
     } else {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Ejemplo n.º 13
0
 // ensures a single instance on the bound object
 // SINGLETON PATTERN
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 14
0
        private async Task InitializeHandlers()
        {
            var cmdHandler = new CommandHandler(_client, _cmdService, Service, _logService);
            await cmdHandler.InitalizeAsync();

            var reactHandle = new ReactionHandler(_client, _cmdService, Service, _logService);
            await reactHandle.InitalizeAsync();

            var musicHandler = new MusicHandler(_client, _lavaNode, _logService);
            await musicHandler.InitalizeAsync();
        }
Ejemplo n.º 15
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
         source    = GetComponent <AudioSource>();
     }
 }
Ejemplo n.º 16
0
 public void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 17
0
 // Start is called before the first frame update
 void Awake()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         _instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Ejemplo n.º 18
0
 void Awake()
 {
     if (music_source)
     {
         DestroyImmediate(gameObject);
     }
     else
     {
         DontDestroyOnLoad(gameObject);
         music_source = this;
     }
 }
Ejemplo n.º 19
0
    public override void Attack()
    {
        float distance = Vector2.Distance(transform.position, m_EnemyTarget.transform.position);

        calculateAttackDistance();
        if (transform.position.x > m_EnemyTarget.transform.position.x)
        {
            m_Facing = FACING_LEFT;
        }
        else
        {
            m_Facing = FACING_RIGHT;
        }
        // if in attack range then attack
        if (distance < m_AttackDistance)
        {
            if (m_AttackDelay <= 0)
            {
                MusicHandler.PlaySound(SoundType.RED_ENEMY_ATTACK);
                m_AttackDelay = DEFAULT_ATTACK_SPEED;
                AI ai = m_EnemyTarget.GetComponent <AI>();
                ai.setHealth(ai.getHealth() - m_Damage);
                if (ai.getHealth() <= 0)
                {
                    m_EnemyTarget = null;
                }
            }
        }
        else
        {
            float   angle  = Mathf.Atan2(m_EnemyTarget.transform.position.y - transform.position.y, m_EnemyTarget.transform.position.x - transform.position.x);
            Vector2 newPos = transform.position;
            newPos.x          += Mathf.Cos(angle) * MOVING_SPEED * Time.fixedDeltaTime;
            newPos.y          += Mathf.Sin(angle) * MOVING_SPEED * Time.fixedDeltaTime;
            transform.position = newPos;
        }
        if (m_Health <= 0)
        {
            // generate heart for player to gain health
            float ran = Random.Range(0, 101);
            if (Debug.isDebugBuild)
            {
                ran = 80;
            }
            if (ran >= 70)
            {
                var heart = SpriteManage.CREATE_SPRITE(SpriteType.HEART);
                heart.transform.position = transform.position;
            }
        }
        checkHealth();
    }
Ejemplo n.º 20
0
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Ejemplo n.º 21
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
         source   = GetComponent <AudioSource>();
         DontDestroyOnLoad(gameObject);
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 22
0
    private void Awake()
    {
        if (_instance == null)
        {
            _instance = this;
        }
        else if (_instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Ejemplo n.º 23
0
    // Start is called before the first frame update
    private void Start()
    {
        // Get reference to music handler
        if (FindObjectsOfType <MusicHandler>()[0] != null)
        {
            musicHandler           = FindObjectsOfType <MusicHandler>()[0];
            _isMusicHandlerNotNull = true;
        }

        // Make sure this object doesn't unload, for the results screen
        transform.SetParent(null);
        DontDestroyOnLoad(transform.gameObject);
    }
Ejemplo n.º 24
0
 private void Awake()
 {
     if (musicHandler == null)
     {
         musicHandler = this;
         GetComponent <AudioSource>().Play();
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 25
0
 void Start()
 {
     DontDestroyOnLoad(this);
     if (MH == null)
     {
         MH = this;
     }
     else
     {
         Destroy(gameObject);
     }
     musicid = 0;
 }
Ejemplo n.º 26
0
 // Start is called before the first frame update
 void Start()
 {
     // If a music handler already has been created, we need to
     // destroy this one.
     if (instance != null)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
     }
 }
Ejemplo n.º 27
0
    // Use this for initialization
    void Awake()
    {
        if (INSTANCE == null)
        {
            INSTANCE = this;

            Audio.volume = Volume;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }
    }
Ejemplo n.º 28
0
 // Start is called before the first frame update
 private void Awake()
 {
     if (!musicHandler)
     {
         SceneManager.sceneLoaded   += OnSceneLoaded;
         SceneManager.sceneUnloaded += OnSceneUnloaded;
         musicHandler = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 29
0
    void Awake()
    {
        if(instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            instance = this;
			GetComponent<AudioSource>().enabled = true;
        }
        DontDestroyOnLoad(this.gameObject);
    }
Ejemplo n.º 30
0
    /// <summary>
    /// Initiates the buttons defaults and sets any needed information
    /// </summary>
    public void Init(int type, bool sustain, float curbeat, int track)
    {
        // Create button
        Beat          = curbeat;
        _gameHandler  = FindObjectOfType <GameHandler>();
        _musicHandler = FindObjectOfType <MusicHandler>();
        var types = sustain ? _gameHandler.HoldTypes : _gameHandler.NoteTypes;

        _renderer        = GetComponent <SpriteRenderer>();
        _renderer.sprite = types[type];
        NoteType         = type;
        Track            = track;
        Sustain          = sustain;
        SerializedButton = new SerializedButton(gameObject, _gameHandler.NoteInputs[NoteType], _gameHandler.NoteInputsAlt[NoteType], this);
    }
 public override void Attack()
 {
     if (m_EnemyTarget != null)
     {
         if (!m_EnemyTarget.active)
         {
             m_EnemyTarget = null;
             return;
         }
         float distance = Vector2.Distance(transform.position, m_EnemyTarget.transform.position);
         calculateAttackDistance();
         if (distance < m_AttackDistance)
         {
             if (m_AttackDelay <= 0)
             {
                 MusicHandler.PlaySound(SoundType.RED_ENEMY_ATTACK);
                 m_AttackDelay = DEFAULT_ATTACK_DELAY;
                 if (m_EnemyTarget.tag == "tree")
                 {
                     m_EnemyTarget.GetComponent <Tree>().m_health--;
                     if (m_EnemyTarget.GetComponent <Tree>().m_health <= 0)
                     {
                         SpriteManage.DESTROY_SPRITE(m_EnemyTarget);
                         m_EnemyTarget = null;
                     }
                 }
                 else if (m_EnemyTarget.tag == "stone")
                 {
                     m_EnemyTarget.GetComponent <Rock>().m_health--;
                     if (m_EnemyTarget.GetComponent <Rock>().m_health <= 0)
                     {
                         SpriteManage.DESTROY_SPRITE(m_EnemyTarget);
                         m_EnemyTarget = null;
                     }
                 }
             }
         }
         // moving to the target
         else
         {
             float   angle = Mathf.Atan2(m_EnemyTarget.transform.position.y - transform.position.y, m_EnemyTarget.transform.position.x - transform.position.x);
             Vector2 pos   = transform.position;
             pos.x += Mathf.Cos(angle) * MOVE_SPEED * Time.fixedDeltaTime;
             pos.y += Mathf.Sin(angle) * MOVE_SPEED * Time.fixedDeltaTime;
             transform.position = pos;
         }
     }
 }
Ejemplo n.º 32
0
        public ServerData(Server UseServer)
        {
            Server = UseServer;

            Music = new MusicHandler(UseServer);
            Music.Run().Forget();

            foreach (var Channel in UseServer.VoiceChannels)
            {
                if (Channel.Name == "Music")
                {
                    Music.OptionalConnectClient(Channel);
                    break;
                }
            }
        }
Ejemplo n.º 33
0
    // Start is called before the first frame update
    void Start()
    {
        DontDestroyOnLoad(gameObject);

        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
        }
        newday   = Resources.Load <AudioClip>("Music/newday");
        ankanwow = Resources.Load <AudioClip>("Music/ankanwow");
        AS       = GetComponent <AudioSource>();
        //PlayNewDaySound();
    }
Ejemplo n.º 34
0
    /*
    ============================================================================
    Init functions
    ============================================================================
    */
    public void Init()
    {
        this.ClearData();
        this.partyHandler = new PartyHandler();

        if(Application.isPlaying)
        {
            if(this.levelHandler == null)
            {
                GameObject tmp = new GameObject("LevelHandler");
                if(GUISystemType.ORK.Equals(DataHolder.GameSettings().guiSystemType))
                {
                    this.levelHandler = (LevelHandler)tmp.AddComponent("LevelHandler");
                }
                else
                {
                    this.levelHandler = (LevelHandlerGUI)tmp.AddComponent("LevelHandlerGUI");
                }
            }
            if(this.musicHandler == null)
            {
                GameObject tmp = new GameObject("MusicHandler");
                this.musicHandler = (MusicHandler)tmp.AddComponent("MusicHandler");
            }
            if(this.dropHandler == null)
            {
                GameObject tmp = new GameObject("DropHandler");
                this.dropHandler = (DropHandler)tmp.AddComponent("DropHandler");
                this.dropHandler.ClearData();
            }
            if(this.dragHandler == null)
            {
                GameObject tmp = new GameObject("DragHandler");
                this.dragHandler = (DragHandler)tmp.AddComponent("DragHandler");
            }
            if(this.windowHandler == null)
            {
                this.windowHandler = new WindowHandler();
            }
            if(this.guiHandler == null)
            {
                GameObject tmp = new GameObject("GUIHandler");
                this.guiHandler = (GUIHandler)tmp.AddComponent("GUIHandler");
            }
        }
    }