Esempio n. 1
0
    /* Load Stats */
    public void LoadPlayerStats(Player2D_StatsHolder _stats)
    {
        string[] statstring = PlayerPrefs.GetString("Player_Stats").Split(new char[] { ',' });

        _stats.Name = statstring[0];
        float tempvalue = 0.0f;

        float.TryParse(statstring[1], out tempvalue);  //Level
        _stats.Level = (int)tempvalue;
        float.TryParse(statstring[2], out tempvalue);  //HP
        _stats.Health = tempvalue;
        float.TryParse(statstring[3], out tempvalue);  //Attack
        _stats.Attack = tempvalue;
        float.TryParse(statstring[4], out tempvalue);  //Stamina
        _stats.Stamina = tempvalue;
        float.TryParse(statstring[5], out tempvalue);  //Defense
        _stats.Defense = tempvalue;
        float.TryParse(statstring[6], out tempvalue);  //MovementSpeed
        _stats.MoveSpeed = tempvalue;
        float.TryParse(statstring[7], out tempvalue);  //gold
        _stats.gold = (int)tempvalue;
        float.TryParse(statstring[8], out tempvalue);  //EXP
        _stats.EXP = tempvalue;
        float.TryParse(statstring[9], out tempvalue);  //MaxEXP
        _stats.MaxEXP = tempvalue;
        float.TryParse(statstring[10], out tempvalue); //MaxHP
        _stats.MaxHealth = tempvalue;
        float.TryParse(statstring[11], out tempvalue); //MaxStamina
        _stats.MaxStamina = tempvalue;
    }
Esempio n. 2
0
    void Start()
    {
        // Pet Manager
        m_PetsManager = GetComponent <PetsManager>();

        // Player
        m_Player      = GameObject.FindGameObjectWithTag("Player").GetComponent <Player2D_Manager>().gameObject;
        m_PlayerStats = GameObject.FindGameObjectWithTag("Player").GetComponent <Player2D_StatsHolder>();
        m_PetsManager.SetPlayer(m_Player);
        m_PetsManager.SetPlayerStats(m_PlayerStats);

        // Pet Variables from Pets Manager
        m_PetsManager.GetPetDestination().Set(0, 0, 0);
        m_PetsManager.SetPetDestination(m_PetsManager.GetPetDestination());
        m_PetsManager.SetDistanceApart(0f);
        m_PetsManager.SetGuardRange(0f);
        m_PetsManager.SetFollowRange(0f);
        m_PetsManager.SetHealRange(0f);

        // StateMachine
        m_StateMachine = new StateMachine();
        m_PetsManager.SetStateMachine(m_StateMachine);
        m_PetsManager.GetStateMachine().AddState(new StateDeerGuard("StateDeerGuard", gameObject));
        m_PetsManager.GetStateMachine().AddState(new StateDeerFollow("StateDeerFollow", gameObject));
        m_PetsManager.GetStateMachine().AddState(new StateDeerTeleport("StateDeerTeleport", gameObject));
        m_PetsManager.GetStateMachine().AddState(new StateDeerHeal("StateDeerHeal", gameObject));
        m_PetsManager.GetStateMachine().SetNextState("StateDeerGuard");

        m_PetsManager.EXPReward = m_PetsManager.EXPRewardScaling * m_PetsManager.Level;
        m_PetsManager.Init();
    }
Esempio n. 3
0
    // Use this for initialization
    public void Init(int _level)
    {
        player      = GameObject.FindGameObjectWithTag("Player").GetComponent <Player2D_Manager>().gameObject;
        playerStats = GameObject.FindGameObjectWithTag("Player").GetComponent <Player2D_StatsHolder>();

        e_spriteManager = GetComponent <SpriteManager>();
        // set default equipments(will be moved to savefile)
        e_spriteManager.SetHeadEquip(SpriteManager.S_Wardrobe.HEADP_NULL);
        e_spriteManager.SetTopEquip(SpriteManager.S_Wardrobe.TOP_NULL);
        e_spriteManager.SetBottomEquip(SpriteManager.S_Wardrobe.BOTTOM_NULL);
        e_spriteManager.SetShoesEquip(SpriteManager.S_Wardrobe.SHOES_NULL);
        e_spriteManager.SetWeaponEquip(SpriteManager.S_Weapon.DAGGER);

        chasingTimer = 4f;
        maxSpeed     = 5f;

        // Setting Skeleton Initial State as IDLE.
        skeletonState           = EnemySkeletonState.IDLE;
        enemyToPatrolTimer      = 5f;
        canCountDownPatrolTimer = false;
        canPatrol = false;
        // Setting the range for Enemy State to be CHASE.
        enemyChaseRange = 5f;
        // Setting the range for Enemy State to be ATTACk.
        enemyAttackRange        = 1f;
        enemyAttackTimer        = 1f;
        canCountDownAttackTimer = false;
        canAttack = false;

        //Initialize Stats from the leveling system
        enemyLevel     = _level;
        levelingSystem = GetComponent <LevelingSystem>();
        levelingSystem.Init(this, false);
    }
Esempio n. 4
0
    /* Save Stats */
    public void SavePref(Player2D_StatsHolder _stats)
    {
        string tempstring = _stats.Name + "," + _stats.Level + "," + _stats.Health + "," + _stats.Attack + ","
                            + _stats.Stamina + "," + _stats.Defense + "," + _stats.movespeed + "," + _stats.gold + ","
                            + _stats.EXP + "," + _stats.MaxEXP + "," + _stats.MaxHealth + "," + _stats.MaxStamina;

        PlayerPrefs.SetString("Player_Stats", tempstring);
    }
Esempio n. 5
0
    void Start()
    {
        // Enemy Manager
        m_EnemyManager = GetComponent <EnemyManager>();

        // Player
        m_Player      = GameObject.FindGameObjectWithTag("Player").GetComponent <Player2D_Manager>().gameObject;
        m_PlayerStats = GameObject.FindGameObjectWithTag("Player").GetComponent <Player2D_StatsHolder>();
        m_EnemyManager.SetPlayer(m_Player);
        m_EnemyManager.SetPlayerStats(m_PlayerStats);

        // Enemy Variables from Enemy Manager
        m_EnemyManager.GetEnemyDestination().Set(0, 0, 0);
        m_EnemyManager.SetEnemyDestination(m_EnemyManager.GetEnemyDestination());
        m_EnemyManager.SetDistanceApart(0f);
        m_EnemyManager.SetChaseRange(0f);
        m_EnemyManager.SetAttackRange(0f);
        m_EnemyManager.SetChangeStateTimer(0f);
        m_EnemyManager.SetAttackTimer(0f);
        m_EnemyManager.SetBoolCanAttack(false);
        m_EnemyManager.SetBoolCanPatrol(false);

        // StateMachine
        m_StateMachine = new StateMachine();
        m_EnemyManager.SetStateMachine(m_StateMachine);
        m_EnemyManager.GetStateMachine().AddState(new StateSkeletonIdle("StateSkeletonIdle", gameObject));
        m_EnemyManager.GetStateMachine().AddState(new StateSkeletonChase("StateSkeletonChase", gameObject));
        m_EnemyManager.GetStateMachine().AddState(new StateSkeletonAttack("StateSkeletonAttack", gameObject));
        m_EnemyManager.GetStateMachine().AddState(new StateSkeletonPatrol("StateSkeletonPatrol", gameObject));
        m_EnemyManager.GetStateMachine().SetNextState("StateSkeletonIdle");

        // Sprite Manager
        m_SpriteManager = GetComponent <SpriteManager>();
        m_EnemyManager.SetSpriteManager(m_SpriteManager);
        m_EnemyManager.GetSpriteManager().SetHeadEquip(SpriteManager.S_Wardrobe.HEADP_NULL);
        m_EnemyManager.GetSpriteManager().SetTopEquip(SpriteManager.S_Wardrobe.TOP_NULL);
        m_EnemyManager.GetSpriteManager().SetBottomEquip(SpriteManager.S_Wardrobe.BOTTOM_NULL);
        m_EnemyManager.GetSpriteManager().SetShoesEquip(SpriteManager.S_Wardrobe.SHOES_NULL);
        m_EnemyManager.GetSpriteManager().SetWeaponEquip(SpriteManager.S_Weapon.DAGGER);

        m_EnemyManager.Level = 1;
        //m_EnemyManager.Waypoint = _wayPoints;
        //m_EnemyManager.CurrWaypointID = _wayPointCurrID;
        m_EnemyManager.EXPReward = m_EnemyManager.EXPRewardScaling * 1;
        m_EnemyManager.Init();
    }
Esempio n. 6
0
    // Use this for initialization
    public void Init(int _level)
    {
        m_playerStats = GameObject.FindGameObjectWithTag("Player").GetComponent <Player2D_StatsHolder>();

        m_level        = _level;
        levelingSystem = GetComponent <LevelingSystem>();
        levelingSystem.Init(this, false);

        /* Initialize State Machine with its states */
        m_StateMachine = new StateMachine();
        m_StateMachine.AddState(new StateBossIdle("StateIdle", gameObject));
        m_StateMachine.AddState(new StateBossAttack("StateAttack", gameObject));
        m_StateMachine.AddState(new StateBossRage("StateRage", gameObject));
        m_StateMachine.SetNextState("StateIdle");

        dead = false;
    }
Esempio n. 7
0
    void Start()
    {
        player      = GameObject.FindGameObjectWithTag("Player").GetComponent <Player2D_Manager>().gameObject;
        playerStats = GameObject.FindGameObjectWithTag("Player").GetComponent <Player2D_StatsHolder>();

        maxSpeed    = 30f;
        followTimer = 2f;

        // The amount of HP that a Pet will use to heal Player.
        addPlayerHP       = 20f;
        HealCoolDownTimer = 10f;
        SpriteRenderTimer = 3f;
        HasPetHeal        = false;
        CanHealCoolDown   = false;
        CanActivateSprite = false;

        // Pet Recovery State
        CanPetRecover   = false;
        HasPetRecover   = false;
        PetRecoverTimer = 20f;

        // Pet current state to be GUARD.
        petState = PetState.FOLLOW;
        // Setting the range for Pet State to be GUARD.
        PetGuardRange = 1f;
        // Setting the range for Pet to heal the Player.
        PetHealRange = 2.5f;
        // Setting the range for Pet State to be TELEPORT.
        PetFollowRange = 5f;
        HasPetTeleport = false;
        // Setting the range for Pet to ATTACK.
        PetAttackRange = 1f;
        HasPetAttack   = false;

        //Initialize Stats from the leveling system
        levelingSystem = GetComponent <LevelingSystem>();
        levelingSystem.Init(this, false);

        // Ignore Collision between Player and Pet.
        Physics2D.IgnoreCollision(GetComponent <Collider2D>(), player.GetComponent <Collider2D>());
    }
Esempio n. 8
0
    // --------------------------------------------------------------------------------------------------------- //
    // Use this for initialization
    void Start()
    {
        /* Stats Things */
        statsHolder = GetComponent <Player2D_StatsHolder>();


        /* Animation */
        animTimer       = 0.0f;
        m_fAniTime      = 0.1f;
        attackClicked   = false;
        p_spriteManager = GetComponent <SpriteManager>();


        // set default equipments(will be moved to savefile)
        p_spriteManager.SetHeadEquip(SpriteManager.S_Wardrobe.HEADP_DEFAULT);
        p_spriteManager.SetTopEquip(SpriteManager.S_Wardrobe.TOP_DEFAULT);
        p_spriteManager.SetBottomEquip(SpriteManager.S_Wardrobe.BOTTOM_DEFAULT);
        p_spriteManager.SetShoesEquip(SpriteManager.S_Wardrobe.SHOES_DEFAULT);
        p_spriteManager.SetWeaponEquip(SpriteManager.S_Weapon.DAGGER);

        // initialising the equipments
        for (int i = 0; i < EquipmentList.Length; ++i)
        {
            EquipmentList[i] = null;
        }

        /* Storing Player Info */
        PlayerSaviour.Instance.LoadInv(Inventory);

        if (PlayerPrefs.GetString("Player_Stats") != "")
        {
            PlayerSaviour.Instance.LoadPlayerStats(statsHolder);
        }

        //Debug.Log("Player Manager: HP - " + statsHolder.Health);
        if (PlayerPrefs.GetInt("NumStoredItems") == 0)
        {
            PlayerEquipmentInit();
        }

        if (PlayerPrefs.GetInt("NumStoredEquipments") == 0)
        {
            PlayerSaviour.Instance.LoadEquipment(EquipmentList);
            Requip();
        }

        cm = GameObject.FindGameObjectWithTag("GameScript").GetComponent <ControlsManager>();

        /* Player Movement */
#if UNITY_EDITOR || UNITY_STANDALONE
        inputX = inputY = 0;
#elif UNITY_ANDROID || UNITY_IPHONE
        inputX = Input.acceleration.x;
        inputY = Input.acceleration.y;
#endif

        m_confusedModifier = 1;
        m_Sprint           = 1.0f; // cannot be zero
        m_maxSprint        = 2.0f; // cannot be zero

        /* Initialising */
        if (GameObject.FindGameObjectWithTag("GameScript").GetComponent <AchievementDisplay>() != null)
        {
            achDis = GameObject.FindGameObjectWithTag("GameScript").GetComponent <AchievementDisplay>();
        }
        invenDis = GameObject.FindGameObjectWithTag("GameScript").GetComponent <Inventory>();
        tutDis   = GameObject.FindGameObjectWithTag("GameScript");
    }
Esempio n. 9
0
 // Use this for initialization
 void Start()
 {
     stats   = GetComponent <Player2D_StatsHolder> ();
     content = GetComponent <Image> ();
 }
Esempio n. 10
0
 // Variables Setter & Getter //
 // Player
 public void SetPlayerStats(Player2D_StatsHolder _statsHolder)
 {
     m_PlayerStats = _statsHolder;
 }