Exemple #1
0
        /// <summary>
        /// Randomly spawns an attack arrow for boss battles.
        /// </summary>
        public AttackArrow SpawnAttackArrow()
        {
            //Instantiate arrow on screen
            if (mainCanvas != null)
            {
                spawnedArrow = Instantiate(attackArrow, mainCanvas.transform, false) as AttackArrow;
            }
            else
            {
                spawnedArrow = Instantiate(attackArrow, GameObject.Find("Main Canvas").transform, false) as AttackArrow;
            }

            if (spawnedArrow == null)
            {
                Debug.LogError("Could not spawn an attack arrow! Somehow it was null. Maybe check the file name in the Resources folder?");
                return(null);
            }

            //Get the RectTransform
            RectTransform rTransform = spawnedArrow.gameObject.GetComponent <RectTransform>();

            //Set position with an offset
            rTransform.anchoredPosition = Vector2.zero + battleGUISpawnOffset;

            //Randomly choose a direction to face
            Array values = Enum.GetValues(typeof(AttackArrowRotationDirection));
            AttackArrowRotationDirection direction = (AttackArrowRotationDirection)values.GetValue(new System.Random().Next(values.Length));

            //Set rotation
            rTransform.rotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, (int)direction));

            return(spawnedArrow as AttackArrow);
        }
        /// <summary>
        /// Handles spawning an attack arrow.
        /// </summary>
        void SpawnAttackArrow()
        {
            Debug.Log("<b>[Battle]</b> Spawn Attack Arrow");

            //Reset the damage multiplyers
            playerCharacter.DamageMultiplyer = 1.0f;
            bossCharacter.DamageMultiplyer   = 1.0f;

            //Spawn the arrow
            attackArrow = GUIManager.Instance.SpawnAttackArrow();
        }
Exemple #3
0
        new void Awake()
        {
            base.Awake();

            //Load some things from resources
            swipeText      = (Resources.Load("GUI/Swipe Text") as GameObject).GetComponent <Text>();
            floatingText   = (Resources.Load("GUI/Floating Text") as GameObject).GetComponent <FloatingText>();
            attackArrow    = (Resources.Load("GUI/Attack Arrow") as GameObject).GetComponent <AttackArrow>();
            blockingSlider = (Resources.Load("GUI/Blocking Slider") as GameObject).GetComponent <BlockingSlider>();

            //Reference some things from the scene
            mainCanvas = GameObject.Find("Main Canvas").GetComponent <Canvas>();
        }