Exemplo n.º 1
0
 public void AddCharacter(BaseVillager chosenVillager)
 {
     if (activeVillagers.Count < characterSlots)
     {
         activeVillagers.Add(chosenVillager);
         UpdateButton(activeVillagers.IndexOf(chosenVillager), chosenVillager);
     }
 }
Exemplo n.º 2
0
 public virtual void AddVillagerToWork(BaseVillager selectedVillager, int slotIndex)
 {
     if (BuildSlotAvailable())
     {
         workingVillagers.Add(selectedVillager);
         selectedVillager.SelectWorkArea(this.gameObject);
         villagerIndexes.Add(baseManager.GetVillagerIndex(selectedVillager));
     }
 }
Exemplo n.º 3
0
    public void UpdateValues(BaseVillager villager)
    {
        characterPortrait = villager.GetPortrait();
        characterName     = villager.GetName();
        characterLevel    = villager.GetLevel();

        panelPortrait.sprite = characterPortrait;
        panelName.text       = characterName;
        panelLevel.text      = "Level: " + characterLevel.ToString();
    }
Exemplo n.º 4
0
    public void CloseCharacterInfoPanel()
    {
        if (villagerReference)
        {
            //villagerReference.gameObject.GetComponent<Renderer>().material.SetFloat("_Outline", 0.0f);

            villagerReference.SetSelected(false);
            villagerReference = null;
        }
        characterPanel.SetActive(false);
    }
Exemplo n.º 5
0
    public void Reset()
    {
        CloseCharacterInfoPanel();

        CloseInventory();
        selectedObject = null;

        villagerReference = null;
        resourceReference = null;
        buildingReference = null;
    }
Exemplo n.º 6
0
    virtual protected void CreateBuilding(BaseVillager characterReference)
    {
        baseManager.RemoveBuildingFromList(this, 0);
        baseManager.AddBuildingToList(this, 1);
        SetMaxHealth(characterReference.GetTaskSkills().construction);
        isBuilt       = true;
        isBeingWorked = false;
        constructor   = characterReference.GetName();
        SetBuildTime(buildTime / 2);

        Destroy(progressSlider);
        //SetMesh();
    }
Exemplo n.º 7
0
 public override void AddVillagerToWork(BaseVillager selectedVillager, int slotIndex)
 {
     if (slotIndex == 0)
     {
         workingVillagers.Add(selectedVillager);
         selectedVillager.SelectWorkArea(this.gameObject);
         villagerIndexes.Add(baseManager.GetVillagerIndex(selectedVillager));
         masterVillager = selectedVillager;
     }
     else if (slotIndex == 1)
     {
         workingVillagers.Add(selectedVillager);
         selectedVillager.SelectWorkArea(this.gameObject);
         villagerIndexes.Add(baseManager.GetVillagerIndex(selectedVillager));
         apprenticeVillager = selectedVillager;
     }
 }
Exemplo n.º 8
0
 public override void RemoveVillagerFromWork(int villager)
 {
     if (villager == 0)
     {
         masterVillager.VillagerStopWork();
         villagerIndexes.Remove(baseManager.GetVillagerIndex(masterVillager));
         workingVillagers.RemoveAt(workingVillagers.IndexOf(masterVillager));
         masterVillager = null;
     }
     else if (villager == 1)
     {
         apprenticeVillager.VillagerStopWork();
         villagerIndexes.Remove(baseManager.GetVillagerIndex(apprenticeVillager));
         workingVillagers.RemoveAt(workingVillagers.IndexOf(apprenticeVillager));
         apprenticeVillager = null;
     }
 }
Exemplo n.º 9
0
    public void AddConstructionPoints(float points, BaseVillager characterReference)
    {
        buildTime -= points;

        AudioSource.PlayClipAtPoint(Resources.Load("Sound/Sound_Building") as AudioClip, transform.position);

        progressSlider.GetComponentInChildren <UnityEngine.UI.Slider>().value = buildTime / initialBuildTime;

        if (buildTime <= 0)
        {
            if (!isBuilt)
            {
                CreateBuilding(characterReference);
            }
            else
            {
                CompleteUpgrade();
            }
        }
    }
Exemplo n.º 10
0
 public virtual void SelectCharacter(BaseVillager chosenVillager)
 {
     if (settingUpQuest)
     {
         characterScroll.GetComponent <CharacterDisplay>().GetActiveQuest().AddCharacter(chosenVillager);
         ToggleQuestMenu(false);
         ToggleCharacterMenu();
         settingUpQuest = false;
     }
     else if (addingToBuilding)
     {
         buildingInfo.GetComponentInChildren <BuildingDisplay>().AddCharacter(chosenVillager, buildingButtonIndex);
         ToggleCharacterMenu();
         ToggleBuildingInfo();
         addingToBuilding = false;
     }
     else
     {
         chosenVillager.SetSelected(true);
         controller.SetVillagerReference(chosenVillager);
         controller.OpenCharacterInfoPanel();
         ToggleCharacterMenu();
     }
 }
Exemplo n.º 11
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            baseManager.TogglePauseMenu(isPaused);
            isPaused = !isPaused;
        }

        if (!isPaused)
        {
            if (Input.GetKeyDown(KeyCode.Mouse1))
            {
                CloseAllMenus();
                selectedObject    = null;
                villagerReference = null;
                buildingReference = null;
                resourceReference = null;
            }

            if (!EventSystem.current.IsPointerOverGameObject())
            {
                if (Input.GetKeyDown(KeyCode.Mouse0))
                {
                    //Debug.Log ("Mouse Click");
                    selectedObject = FindObjectUnderMouse();

                    if (selectedObject != null)
                    {
                        //Debug.Log ("Object Selected");

                        if (selectedObject.GetComponent <BaseVillager>())
                        {
                            //Debug.Log ("Villager Found");

                            if (villagerReference == null)
                            {
                                villagerReference = selectedObject.GetComponent <BaseVillager>();

                                villagerReference.SetSelected(true);
                                OpenCharacterInfoPanel();
                            }
                            else
                            {
                                CloseCharacterInfoPanel();
                            }

                            if (buildingReference != null)
                            {
                                CloseBuildingInfoPanel();
                            }
                        }
                        else if (selectedObject.GetComponent <ResourceTile>())
                        {
                            //Debug.Log ("Resources Found");
                            resourceReference = selectedObject.GetComponent <ResourceTile>();

                            if (villagerReference != null)
                            {
                                //Debug.Log ("Setting Work Area (Controller)");
                                villagerReference.SelectWorkArea(resourceReference.gameObject);

                                CloseCharacterInfoPanel();
                            }

                            if (buildingReference != null)
                            {
                                CloseBuildingInfoPanel();
                            }

                            resourceReference = null;
                        }
                        else if (selectedObject.GetComponent <BaseBuilding>())
                        {
                            //Debug.Log ("Building Found");

                            if (buildingReference != null)
                            {
                                //Close panel and remove reference
                                CloseBuildingInfoPanel();
                            }
                            else
                            {
                                //Set building reference and open info panel
                                buildingReference = selectedObject.GetComponent <BaseBuilding>();
                                if (buildingReference.IsBuilt() == true)
                                {
                                    OpenBuildingInfoPanel();
                                }
                                else
                                {
                                    buildingReference = null;
                                }
                            }

                            if (villagerReference != null)
                            {
                                //buildingReference.OnClicked(villagerReference);

                                CloseCharacterInfoPanel();
                            }
                        }
                        else if (villagerReference != null)
                        {
                            Ray hitPosition = Camera.main.ScreenPointToRay(Input.mousePosition);

                            if (Physics.Raycast(hitPosition, out hit, Mathf.Infinity))
                            {
                                villagerReference.SetTargetPosition(new Vector3(hit.point.x, 0, hit.point.z));
                            }

                            CloseCharacterInfoPanel();
                        }
                    }
                    else
                    {
                        //Debug.Log ("Object is null");
                    }
                }
            }
        }
    }
Exemplo n.º 12
0
 public void AddVillagerToList(BaseVillager villager)
 {
     villagerList.Add(villager);
 }
Exemplo n.º 13
0
 public virtual void OnClicked(BaseVillager selectedVillager)
 {
 }
Exemplo n.º 14
0
 void I_Item.CalculateBaseStats(BaseVillager villagerReference)
 {
 }
Exemplo n.º 15
0
 public void SetVillagerReference(BaseVillager newVillager)
 {
     villagerReference = newVillager;
 }
Exemplo n.º 16
0
    public void OpenCharacterInfoPanel(BaseVillager villager)
    {
        villagerReference = villager;

        villagerReference.gameObject.GetComponent <Renderer>().material.SetFloat("_Outline", 0.2f);

        selectedCharacterInfo       = villagerReference.GetCharacterInfo();
        selectedCharacterTaskSkills = villagerReference.GetTaskSkills();

        for (int i = 0; i < infoText.Length; i++)
        {
            switch (i)
            {
            case 1:
                infoText [i].text = selectedCharacterInfo.characterName;
                break;

            case 2:
                infoText[i].text = selectedCharacterInfo.characterName;
                break;

            case 3:
                if (selectedCharacterInfo.characterSex == 1)
                {
                    infoText [i].text = "Male";
                }
                else
                {
                    infoText [i].text = "Female";
                }
                break;

            case 5:
                infoText [i].text = selectedCharacterInfo.characterLevel.ToString();
                break;

            case 8:
                infoText [i].text = selectedCharacterInfo.characterAttributes.fitness.ToString();
                break;

            case 10:
                infoText [i].text = selectedCharacterInfo.characterAttributes.nimbleness.ToString();
                break;

            case 12:
                infoText [i].text = selectedCharacterInfo.characterAttributes.curiosity.ToString();
                break;

            case 14:
                infoText [i].text = selectedCharacterInfo.characterAttributes.focus.ToString();
                break;

            case 16:
                infoText [i].text = selectedCharacterInfo.characterAttributes.charm.ToString();
                break;

            case 19:
                infoText [i].text = selectedCharacterInfo.characterCombatSkills.brawling.ToString();
                break;

            case 21:
                infoText [i].text = selectedCharacterInfo.characterCombatSkills.sword.ToString();
                break;

            case 23:
                infoText [i].text = selectedCharacterInfo.characterCombatSkills.longsword.ToString();
                break;

            case 25:
                infoText [i].text = selectedCharacterInfo.characterCombatSkills.axe.ToString();
                break;

            case 27:
                infoText [i].text = selectedCharacterInfo.characterCombatSkills.polearm.ToString();
                break;

            case 29:
                infoText [i].text = selectedCharacterInfo.characterCombatSkills.bow.ToString();
                break;

            case 31:
                infoText [i].text = selectedCharacterInfo.characterCombatSkills.dodge.ToString();
                break;

            case 33:
                infoText [i].text = selectedCharacterInfo.characterCombatSkills.armor.ToString();
                break;

            case 36:
                infoText [i].text = selectedCharacterTaskSkills.mining.ToString();
                break;

            case 38:
                infoText [i].text = selectedCharacterTaskSkills.woodcutting.ToString();
                break;

            case 40:
                infoText [i].text = selectedCharacterTaskSkills.blacksmithing.ToString();
                break;

            case 42:
                infoText [i].text = selectedCharacterTaskSkills.weaponCrafting.ToString();
                break;

            case 44:
                infoText [i].text = selectedCharacterTaskSkills.armorCrafting.ToString();
                break;

            case 46:
                infoText [i].text = selectedCharacterTaskSkills.tailoring.ToString();
                break;

            case 48:
                infoText [i].text = selectedCharacterTaskSkills.farming.ToString();
                break;

            case 50:
                infoText [i].text = selectedCharacterTaskSkills.construction.ToString();
                break;

            case 52:
                infoText [i].text = selectedCharacterTaskSkills.sailing.ToString();
                break;

            case 54:
                infoText [i].text = villagerReference.GetEquippedWeapon().GetItemName();
                break;

            case 56:
                infoText [i].text = villagerReference.GetOffHandWeapon().GetItemName();
                break;

            case 58:
                infoText [i].text = villagerReference.GetEquippedArmor().GetItemName();
                break;
            }
        }

        characterPanel.SetActive(true);
    }
Exemplo n.º 17
0
 private void UpdateButton(int value, BaseVillager villager)
 {
     buttonList [value].GetComponentInChildren <Image> ().sprite   = villager.GetPortrait();
     buttonList [value].GetComponentsInChildren <Text> () [0].text = villager.GetName();
     buttonList [value].GetComponentsInChildren <Text> () [1].text = villager.GetLevel().ToString();
 }
 public void AddCharacter(BaseVillager newVillager, int buttonIndex)
 {
     buildingReference.AddVillagerToWork(newVillager, buttonIndex);
     buildingReference.SetUpInfoPanel();
 }
Exemplo n.º 19
0
 public int GetVillagerIndex(BaseVillager villager)
 {
     return(villagerList.IndexOf(villager));
 }
Exemplo n.º 20
0
 public void RemoveVillagerFromList(BaseVillager villager)
 {
     villagerList.Remove(villager);
     CheckVillagerCount();
 }
Exemplo n.º 21
0
    void I_Item.CalculateBaseStats(BaseVillager villagerReference)
    {
        float smithingBonus = baseWeaponValue + (1 + (villagerReference.GetTaskSkills().weaponCrafting)) + (villagerReference.GetTaskSkills().blacksmithing);

        SetBaseScore(smithingBonus);
    }
Exemplo n.º 22
0
 public void OpenPanel(BaseVillager villager)
 {
 }
Exemplo n.º 23
0
    public bool LoadGame()
    {
        //Debug.Log ("Loading Game");

        controller.Reset();

        //Load file
        if (File.Exists(Application.persistentDataPath + "/baseInfo.dat"))
        {
            BinaryFormatter formatter  = new BinaryFormatter();
            FileStream      fileStream = File.Open(Application.persistentDataPath + "/baseInfo.dat", FileMode.Open);
            GameData        gameData   = (GameData)formatter.Deserialize(fileStream);
            fileStream.Close();

            //Set supply values
            supplyStone  = gameData.supplyStone;
            supplyWood   = gameData.supplyWood;
            supplyFood   = gameData.supplyFood;
            maxVillagers = gameData.maxVillagers;

            //Remove villagers from world
            foreach (BaseVillager villager in villagerList)
            {
                Destroy(villager.gameObject);
            }

            //Clear villager array
            villagerList.Clear();

            //Clear Character Menu
            characterScroll.GetComponent <CharacterDisplay>().RemoveAllButtons();

            //Load Villagers
            foreach (VillagerData villager in gameData.villagerList)
            {
                GameObject newVillager = SpawnVillager();

                BaseVillager toAdd = newVillager.GetComponent <BaseVillager> ();
                toAdd.Load(villager);
            }

            //Load Quests
            GetComponent <QuestManager>().Load(gameData.questList);

            //Destroy all buildings in world ready to load
            foreach (BaseBuilding building in buildingList)
            {
                Destroy(building.gameObject);
            }
            buildingList.Clear();
            foreach (BaseBuilding building in toBeBuilt)
            {
                Destroy(building.gameObject);
            }
            toBeBuilt.Clear();
            foreach (BaseBuilding building in toBeUpgraded)
            {
                Destroy(building.gameObject);
            }
            toBeUpgraded.Clear();

            //Load Buildings
            foreach (BuildingData building in gameData.toBeBuilt)
            {
                GameObject newBuilding = Instantiate(Resources.Load(building.loadPath)) as GameObject;

                BaseBuilding toAdd = newBuilding.GetComponent <BaseBuilding>();
                toAdd.Load(building, this);
                toBeBuilt.Add(toAdd);
            }
            foreach (BuildingData building in gameData.buildingList)
            {
                GameObject newBuilding = Instantiate(Resources.Load(building.loadPath)) as GameObject;

                BaseBuilding toAdd = newBuilding.GetComponent <BaseBuilding>();
                toAdd.Load(building, this);
                buildingList.Add(toAdd);
            }

            foreach (BuildingData building in gameData.toBeUpgraded)
            {
                GameObject newBuilding = Instantiate(Resources.Load(building.loadPath)) as GameObject;

                BaseBuilding toAdd = newBuilding.GetComponent <BaseBuilding> ();
                toAdd.Load(building, this);
                toBeUpgraded.Add(toAdd);
            }


            inventoryReference.ClearInventory();

            //Load Inventory
            inventoryReference.Load(gameData.inventoryData);

            attackTimer    = gameData.attackTimer;
            attackTimerSet = true;

            Debug.Log("Game Loaded");

            return(true);
        }
        Debug.Log("Game Failed to Load");


        return(false);
    }
    protected override void CreateBuilding(BaseVillager characterReference)
    {
        baseManager.IncreaseVillagerCap(villagerSlots);

        base.CreateBuilding(characterReference);
    }
Exemplo n.º 25
0
    void I_Item.CalculateBaseStats(BaseVillager villagerReference)
    {
        float smithingBonus = baseArmorValue + (1 + (villagerReference.GetTaskSkills().armorCrafting / 100)) * (villagerReference.GetTaskSkills().blacksmithing / 100);

        SetBaseScore(smithingBonus);
    }