//called at intialisation
    void Start()
    {
        //gets the button listener
        buttonListen = (GameObject.FindGameObjectWithTag("GameController")).GetComponent <ButtonListener> ();

        //sets the movedirection to zero
        moveDirection = Vector2.zero;

        //gets the physics controller
        controller = GetComponent <Rigidbody2D>();

        //gets the animator
        animator = GetComponent <Animator> ();

        //sets health and healthbar
        health    = StartingHealth;
        healthBar = GameObject.FindGameObjectWithTag("HealthBar");
        healthBar.GetComponent <Slider> ().value = health;

        //sets ammo and ammo count
        //addAmmoCount(StartingRangeAmmo);
        //RangeAmmoCountBox = GameObject.FindGameObjectWithTag ("AmmoCount");

        //gets objects for shooting
        shootCon   = GetComponent <ShootingController>();
        lineRender = trajectoryObject.GetComponent <LineRenderer>();

        //closes line renderer
        lineRender.gameObject.SetActive(false);

        //sets defualt of active
        //if (activeCount == null)
        //    activeCount = PrimaryAmmoCount;
        if (PrimarySelected)
        {
            setActiveAmmoPrimary(true);
        }

        //gets sound object
        ASound = GetComponent <AttackSoundEffect>();
    }
    // Use this for initialization
    void Awake()
    {
        //closes overlay
        overlay.SetActive(false);

        //sets target to player
        target       = GameObject.FindGameObjectWithTag("Player").transform;
        playerHitBox = GameObject.FindGameObjectWithTag("Player").GetComponent <ControllerPlayer> ().hitBox;

        //sets instance nav agent
        nav = GetComponent <NavigateAgent> ();

        //gets the path follower
        follow = GetComponent <PathFollower> ();

        //gets animator of instance
        animator = GetComponent <Animator> ();

        //gets rigidbody
        controller = GetComponent <Rigidbody2D> ();

        //gets shooting controller
        shootCon = GetComponent <ShootingController>();

        //sets health and death state
        health  = StartingHealth;
        onDeath = false;

        if (rangeAngle == Vector2.zero)
        {
            rangeAngle = new Vector2(1f, 1f);
        }

        //gets sound
        ASound = GetComponent <AttackSoundEffect>();
    }
Esempio n. 3
0
        /// <summary>
        /// Builds the string of the character's information.
        /// </summary>
        /// <param name="manager">Main window manager</param>
        /// <returns>String for the DSL</returns>
        public string ToString(MainWindowManager manager)
        {
            int    realSpeed;
            string total;

            ImageMovingUp    = ImageMovingUp.Replace('\\', '/');
            ImageMovingDown  = ImageMovingDown.Replace('\\', '/');
            ImageMovingLeft  = ImageMovingLeft.Replace('\\', '/');
            ImageMovingRight = ImageMovingRight.Replace('\\', '/');

            if (!String.IsNullOrEmpty(ImageAttackingUp))
            {
                ImageAttackingUp    = ImageAttackingUp.Replace('\\', '/');
                ImageAttackingDown  = ImageAttackingDown.Replace('\\', '/');
                ImageAttackingLeft  = ImageAttackingLeft.Replace('\\', '/');
                ImageAttackingRight = ImageAttackingRight.Replace('\\', '/');
            }

            if (!String.IsNullOrEmpty(AttackSoundEffect))
            {
                AttackSoundEffect = AttackSoundEffect.Replace('\\', '/');
            }

            if (!String.IsNullOrEmpty(ShootSoundEffect))
            {
                ShootSoundEffect = ShootSoundEffect.Replace('\\', '/');
            }

            if (!String.IsNullOrEmpty(CastSoundEffect))
            {
                CastSoundEffect = CastSoundEffect.Replace('\\', '/');
            }

            if (Speed == "slow")
            {
                realSpeed = 2;
            }
            else if (Speed == "normal")
            {
                realSpeed = 3;
            }
            else
            {
                realSpeed = 4;
            }

            total = "\t<character>\r\n" +
                    "\t\t<character_name>" + Name + "</character_name>\r\n" +
                    "\t\t<character_image_up>" + ImageMovingUp + "</character_image_up>\r\n" +
                    "\t\t<character_image_down>" + ImageMovingDown + "</character_image_down>\r\n" +
                    "\t\t<character_image_left>" + ImageMovingLeft + "</character_image_left>\r\n" +
                    "\t\t<character_image_right>" + ImageMovingRight + "</character_image_right>\r\n" +
                    "\t\t<character_image_attack_up>" + ImageAttackingUp + "</character_image_attack_up>\r\n" +
                    "\t\t<character_image_attack_down>" + ImageAttackingDown + "</character_image_attack_down>\r\n" +
                    "\t\t<character_image_attack_left>" + ImageAttackingLeft + "</character_image_attack_left>\r\n" +
                    "\t\t<character_image_attack_right>" + ImageAttackingRight + "</character_image_attack_right>\r\n" +
                    "\t\t<character_framecount_iddle>" + FrameCount + "</character_framecount_iddle>\r\n" +
                    "\t\t<character_framecount_attacking>" + FrameAttackingCount + "</character_framecount_attacking>\r\n" +
                    "\t\t<character_initial_state>" + InitialState + "</character_initial_state>\r\n" +
                    "\t\t<character_x_position>" + PositionX + "</character_x_position>\r\n" +
                    "\t\t<character_y_position>" + PositionY + "</character_y_position>\r\n" +
                    "\t\t<character_speed>" + realSpeed + "</character_speed>\r\n" +
                    "\t\t<character_key_up>" + manager.KeyUp + "</character_key_up>\r\n" +
                    "\t\t<character_key_down>" + manager.KeyDown + "</character_key_down>\r\n" +
                    "\t\t<character_key_left>" + manager.KeyLeft + "</character_key_left>\r\n" +
                    "\t\t<character_key_right>" + manager.KeyRight + "</character_key_right>\r\n" +
                    "\t\t<character_key_attack>" + manager.KeyAttack + "</character_key_attack>\r\n" +
                    "\t\t<character_key_shoot>" + manager.KeyShoot + "</character_key_shoot>\r\n" +
                    "\t\t<character_key_cast>" + manager.KeyUseAbility + "</character_key_cast>\r\n" +
                    "\t\t<character_key_change_melee>" + manager.KeyChangeMelee + "</character_key_change_melee>\r\n" +
                    "\t\t<character_key_change_distance>" + manager.KeyChangeDistance + "</character_key_change_distance>\r\n" +
                    "\t\t<character_key_change_ability>" + manager.KeyChangeAbility + "</character_key_change_ability>\r\n" +
                    "\t\t<character_key_action>" + manager.KeyAction + "</character_key_action>\r\n" +
                    "\t\t<character_music_attack>" + AttackSoundEffect + "</character_music_attack>\r\n" +
                    "\t\t<character_music_shoot>" + ShootSoundEffect + "</character_music_shoot>\r\n" +
                    "\t\t<character_music_cast>" + CastSoundEffect + "</character_music_cast>\r\n" +
                    "\t\t<character_strenght>" + Strenght + "</character_strenght>\r\n" +
                    "\t\t<character_dexterity>" + Dexterity + "</character_dexterity>\r\n" +
                    "\t\t<character_intelligence>" + Intelligence + "</character_intelligence>\r\n" +
                    "\t\t<character_hit_points>" + HitPoints + "</character_hit_points>\r\n" +
                    "\t\t<character_mana_points>" + Mana + "</character_mana_points>\r\n";

            if (Melee != null)
            {
                Melee.ImageWeapon = Melee.ImageWeapon.Replace('\\', '/');

                int weaponSpeed;

                if (Melee.Speed == "slow")
                {
                    weaponSpeed = 1;
                }
                else if (Melee.Speed == "normal")
                {
                    weaponSpeed = 2;
                }
                else
                {
                    weaponSpeed = 3;
                }

                total += "\t\t<melee>\r\n" +
                         "\t\t\t<melee_image>" + Melee.ImageWeapon + "</melee_image>\r\n" +
                         "\t\t\t<melee_damage>" + Melee.Damage + "</melee_damage>\r\n" +
                         "\t\t\t<melee_speed>" + weaponSpeed + "</melee_speed>\r\n" +
                         "\t\t</melee>\r\n";
            }

            if (Distance != null)
            {
                Distance.ImageWeapon     = Distance.ImageWeapon.Replace('\\', '/');
                Distance.ImageArrowUp    = Distance.ImageArrowUp.Replace('\\', '/');
                Distance.ImageArrowDown  = Distance.ImageArrowDown.Replace('\\', '/');
                Distance.ImageArrowLeft  = Distance.ImageArrowLeft.Replace('\\', '/');
                Distance.ImageArrowRight = Distance.ImageArrowRight.Replace('\\', '/');

                int weaponSpeed;

                if (Distance.Speed == "slow")
                {
                    weaponSpeed = 3;
                }
                else if (Distance.Speed == "normal")
                {
                    weaponSpeed = 4;
                }
                else
                {
                    weaponSpeed = 5;
                }

                total += "\t\t<distance>\r\n" +
                         "\t\t\t<distance_image>" + Distance.ImageWeapon + "</distance_image>\r\n" +
                         "\t\t\t<distance_damage>" + Distance.Damage + "</distance_damage>\r\n" +
                         "\t\t\t<distance_speed>" + weaponSpeed + "</distance_speed>\r\n" +
                         "\t\t\t<distance_bullet_image_up>" + Distance.ImageArrowUp + "</distance_bullet_image_up>\r\n" +
                         "\t\t\t<distance_bullet_image_down>" + Distance.ImageArrowDown + "</distance_bullet_image_down>\r\n" +
                         "\t\t\t<distance_bullet_image_left>" + Distance.ImageArrowLeft + "</distance_bullet_image_left>\r\n" +
                         "\t\t\t<distance_bullet_image_right>" + Distance.ImageArrowRight + "</distance_bullet_image_right>\r\n" +
                         "\t\t</distance>\r\n";
            }

            foreach (Ability ability in manager.Abilities)
            {
                ability.ImageAbility = ability.ImageAbility.Replace('\\', '/');

                if (ability.Type == "heal")
                {
                    total += "\t\t<heal_ability>\r\n" +
                             "\t\t\t<heal_ability_image>" + ability.ImageAbility + "</heal_ability_image>\r\n" +
                             "\t\t\t<heal_ability_mana>" + ability.Mana + "</heal_ability_mana>\r\n" +
                             "\t\t\t<heal_ability_effect>" + ability.Effect + "</heal_ability_effect>\r\n" +
                             "\t\t</heal_ability>\r\n";
                }
                else if (ability.Type == "attack")
                {
                    int abilitySpeed;

                    if (ability.Speed == "slow")
                    {
                        abilitySpeed = 3;
                    }
                    else if (ability.Speed == "normal")
                    {
                        abilitySpeed = 4;
                    }
                    else
                    {
                        abilitySpeed = 5;
                    }

                    ability.ImageAttackUp    = ability.ImageAttackUp.Replace('\\', '/');
                    ability.ImageAttackDown  = ability.ImageAttackDown.Replace('\\', '/');
                    ability.ImageAttackLeft  = ability.ImageAttackLeft.Replace('\\', '/');
                    ability.ImageAttackRight = ability.ImageAttackRight.Replace('\\', '/');

                    total += "\t\t<attack_ability>\r\n" +
                             "\t\t\t<attack_ability_image>" + ability.ImageAbility + "</attack_ability_image>\r\n" +
                             "\t\t\t<attack_ability_mana>" + ability.Mana + "</attack_ability_mana>\r\n" +
                             "\t\t\t<attack_ability_damage>" + ability.Effect + "</attack_ability_damage>\r\n" +
                             "\t\t\t<attack_ability_speed>" + abilitySpeed + "</attack_ability_speed>\r\n" +
                             "\t\t\t<attack_ability_bullet_image_up>" + ability.ImageAttackUp + "</attack_ability_bullet_image_up>\r\n" +
                             "\t\t\t<attack_ability_bullet_image_down>" + ability.ImageAttackDown + "</attack_ability_bullet_image_down>\r\n" +
                             "\t\t\t<attack_ability_bullet_image_left>" + ability.ImageAttackLeft + "</attack_ability_bullet_image_left>\r\n" +
                             "\t\t\t<attack_ability_bullet_image_right>" + ability.ImageAttackRight + "</attack_ability_bullet_image_right>\r\n" +
                             "\t\t</attack_ability>\r\n";
                }
                else
                {
                    int totalDuration = ability.Duration * 56;

                    total += "\t\t<augmentation_ability>\r\n" +
                             "\t\t\t<augmentation_ability_image>" + ability.ImageAbility + "</augmentation_ability_image>\r\n" +
                             "\t\t\t<augmentation_ability_affect>" + ability.Affect + "</augmentation_ability_affect>\r\n" +
                             "\t\t\t<augmentation_ability_effect>" + ability.Effect + "</augmentation_ability_effect>\r\n" +
                             "\t\t\t<augmentation_ability_mana>" + ability.Mana + "</augmentation_ability_mana>\r\n" +
                             "\t\t\t<augmentation_ability_duration>" + totalDuration + "</augmentation_ability_duration>\r\n" +
                             "\t\t</augmentation_ability>\r\n";
                }
            }

            total += "\t</character>\r\n";

            return(total);
        }