Пример #1
0
    public IEnumerator VillageIsNotNull()
    {
        LoadMyScene();

        yield return(new WaitForFixedUpdate());

        GameObject currObj = GameObject.Find("Village");

        villCont = currObj.GetComponent <VillageController>();
        Assert.IsNotNull(villCont);

        yield return(null);
    }
    // Use this for initialization
    void Start()
    {
        villageMenu.enabled = false;

        villageController = gameObject.GetComponent <VillageController>();
        Transform card = Instantiate(villageCard, villageMenu.transform, false);

        card.transform.Find("VillageName").GetComponent <Text>().text = villageController.village.Name;
        card.transform.Find("VillageType").GetComponent <Text>().text = villageController.village.VillageType;
        card.transform.Find("Price").GetComponent <Text>().text       = villageController.village.ResourceProduced.PriceRange.Max.ToString();
        card.transform.Find("Resource").GetComponent <Text>().text    = villageController.village.ResourceProduced.Resource.DisplayName;
        card.transform.Find("BuyButton").GetComponent <Button>().onClick.AddListener(PlayerBuyGood);
    }
Пример #3
0
    public IEnumerator TestVillageGrowthChangeSprite()
    {
        LoadMyScene();

        yield return(new WaitForFixedUpdate());

        GameObject currObj = GameObject.Find("Village");

        villCont = currObj.GetComponent <VillageController>();
        Sprite sprite1 = currObj.GetComponent <SpriteRenderer>().sprite;

        villCont.IncreaseSize();
        GameObject nextObj = GameObject.Find("Village");

        villCont = nextObj.GetComponent <VillageController>();
        Sprite sprite2 = nextObj.GetComponent <SpriteRenderer>().sprite;

        yield return(new WaitForFixedUpdate());

        Assert.IsFalse(sprite1.Equals(sprite2));
    }
Пример #4
0
    public IEnumerator TestVillageGrowInSize()
    {
        LoadMyScene();

        yield return(new WaitForFixedUpdate());

        GameObject currObj = GameObject.Find("Village");

        villCont = currObj.GetComponent <VillageController>();
        Vector3 size1 = villCont.GetComponent <BoxCollider2D>().bounds.size;

        villCont.IncreaseSize();
        GameObject nextObj = GameObject.Find("Village");

        villCont = nextObj.GetComponent <VillageController>();
        Vector3 size2 = villCont.GetComponent <BoxCollider2D>().bounds.size;

        yield return(new WaitForFixedUpdate());

        Assert.AreNotEqual(size1, size2);
        Debug.Log(size1 + " " + size2);
    }
Пример #5
0
    void Awake()
    {
        data = GameObject.FindWithTag("Data").GetComponent <PersistentData>();
        villageController = gameObject.GetComponent <VillageController>();
        player            = GameObject.FindWithTag("Player").GetComponent <PlayerController>();
        npcController     = GameObject.Find("NPCs").GetComponent <NPCController>();

        foreach (Tilemap map in FindObjectsOfType <Tilemap>())
        {
            if (map.name == "FloorMap")
            {
                floorMap = map;
            }
            else if (map.name == "LeftWallMap")
            {
                leftWallMap = map;
            }
            else if (map.name == "RightWallMap")
            {
                rightWallMap = map;
            }
            else if (map.name == "BlockMap")
            {
                blockMap = map;
            }
            else if (map.name == "RoofMap")
            {
                roofMap = map;
            }
        }
        rooms = new List <Room>();
        rooms.Add(new Room(new Vector3Int(5, 0, 0), new Vector3Int(2, -3, 0)));
        rooms.Add(new Room(new Vector3Int(4, 9, 0), new Vector3Int(1, 4, 0)));

        // -- NEW SHIT! -- //
        GetWorldTiles();
        foreach (KeyValuePair <Vector3Int, WorldTile> kv in roofTiles)
        {
            //Debug.Log("Tile " + kv.Value.Name + " is at: " + kv.Key);
        }

        /*WorldTile _tile;
         * if (roofTiles.TryGetValue(new Vector3Int(4,-2,0), out _tile)) {
         *  Debug.Log("Tile " + _tile.Name + " costs: " + _tile.Cost);
         *  _tile.TilemapMember.SetTileFlags(_tile.LocalPlace, TileFlags.None);
         *  _tile.TilemapMember.SetColor(_tile.LocalPlace, Color.blue);
         * }*/
        // -- --------- -- //

        activeRoofCells      = new List <Vector3Int>();
        activeLeftWallCells  = new List <Vector3Int>();
        activeRightWallCells = new List <Vector3Int>();

        tiles = new Dictionary <string, Tile>();
        tiles.Add("leftWall", Resources.Load <Tile>("Tiles/GreenVillage/leftWall"));
        tiles.Add("rightWall", Resources.Load <Tile>("Tiles/GreenVillage/rightWall"));
        tiles.Add("leftDoor", Resources.Load <Tile>("Tiles/GreenVillage/leftDoor"));
        tiles.Add("leftDoorOpen", Resources.Load <Tile>("Tiles/GreenVillage/leftDoorOpen"));
        tiles.Add("rightDoor", Resources.Load <Tile>("Tiles/GreenVillage/rightDoor"));
        tiles.Add("rightDoorOpen", Resources.Load <Tile>("Tiles/GreenVillage/rightDoorOpen"));

        notableCells = new Dictionary <string, Vector3Int>();
        notableCells.Add("stairsDown", new Vector3Int(0, -9, 0));
        notableCells.Add("shopkeeper", new Vector3Int(5, -2, 0));

        villageController.UpdateNotables(notableCells);
    }
Пример #6
0
	// Use this for initialization
	void Start ()
	{
		villageCon = GameObject.FindGameObjectWithTag("Village").GetComponent<VillageController>();
		gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameController>();
		village = GameObject.Find("Village");
	}
Пример #7
0
    private void DifficultyTimeFrame()
    {
        // does 20, 19, 18, 17, 16, 15 all the way to 10 seconds it changes difficulty
        // Note: Default values (20 - timeRemoved), (timeRemoved <= 10)
        if (secondsToIncreaseDifficulty == initialDifficultyTime - timeRemoved)
        {
            if (Debug.isDebugBuild)
            {
                Debug.Log("Difficulty Increase activated");
            }

            if (timeRemoved < maxDifficultyTime)
            {
                timeRemoved++;
            }

            /*
             *  The Spawn multipler determines how much time is seperated for each meteorite to spawn.
             *  The multipler starts at 0.75f and decreases 0.035f everytime this method is called.
             *  The values will keep changing until it reaches 0.40f.
             *  Starts at 0.90, decreases every .05 and maxs at 0.4 (does it 10 times)
             */
            if (spawnDelayMultiplier >= 0.4f)
            {
                spawnDelayMultiplier -= 0.1f;
            }

            /*
             *  The Speed of meteorites will be determined by this condition.
             *  The initial speed of the meteorites will start from x1 speed.
             *  Each Time this method is called the meteorites speed will increase by 0.035f.
             *  The maximum speed the meteorites will go is x1.75.
             *  Starts at 1.00, increases every .035 and maxs at 1.75 (does it 21-22 times)
             */
            if (speedMultiplier <= 1.75f)
            {
                Assert.AreEqual(true, speedMultiplier <= 1.75f);

                if (Debug.isDebugBuild)
                {
                    Debug.Log("Speed Multipler for each meteorite: " + speedMultiplier);
                }

                speedMultiplier += 0.035f;
            }

            // starts at 0.40, increases every .05 and maxs at 0.80 (does it 10? times)
            if (directionChangeMultiplier <= 0.80f)
            {
                directionChangeMultiplier += .05f;
            }

            secondsToIncreaseDifficulty = 0;      // Reset countdown timer for difficulty change
            difficultyUpdated           = true;   // Notifies that difficulty has changed

            // Calling this in this object, because it sometimes won't call in the other
            GameObject village = GameObject.Find("Village");

            if (village != null)
            {
                VillageController villageController = village.GetComponent <VillageController>();
                villageController.IncreaseSize();
            }
        }
    }
Пример #8
0
    void Start()
    {
        // Load Controllers
        data     = GameObject.FindWithTag("Data").GetComponent <PersistentData>();
        animator = gameObject.GetComponent <Animator>();
        // Load Map Controllers
        Grid grid = FindObjectOfType <Grid>();

        foreach (Tilemap map in FindObjectsOfType <Tilemap>())
        {
            if (map.name == "FloorMap")
            {
                floorMap = map;
            }
            else if (map.name == "LeftWallMap")
            {
                leftWallMap = map;
            }
            else if (map.name == "RightWallMap")
            {
                rightWallMap = map;
            }
            else if (map.name == "BlockMap")
            {
                blockMap = map;
            }
        }
        dungeonController = floorMap.GetComponent <DungeonController>();
        if (dungeonController != null)
        {
            mapType        = "Dungeon";
            NotableCollide = dungeonController.NotableCollide;
            OpenDoor       = dungeonController.OpenDoor;
            OpenChest      = dungeonController.OpenChest;
        }
        villageController = floorMap.GetComponent <VillageController>();
        if (villageController != null)
        {
            mapType        = "Village";
            NotableCollide = villageController.NotableCollide;
            OpenDoor       = villageController.OpenDoor;
            FetchPosition  = villageController.FetchPosition;
        }
        maps = new Dictionary <string, Tilemap>();
        maps.Add("left", leftWallMap);
        maps.Add("right", rightWallMap);
        uiController = GameObject.Find("UICanvas").GetComponent <UIController>();
        canvas       = GameObject.FindWithTag("WorldCanvas");

        // Load Resources
        walkNames = new string[4] {
            "walkUp", "walkRight", "walkDown", "walkLeft"
        };
        attackNames = new string[4] {
            "attackUp", "attackRight", "attackDown", "attackLeft"
        };
        targetPosition = this.transform.position;
        textFab        = Resources.Load("Prefabs/DamageText") as GameObject;

        // Set Attributes
        tilePosition = new Vector3Int(0, 0, 0);
        if (FetchPosition != null)
        {
            tilePosition = FetchPosition();
            Vector3 pos = PathFinder.TileToWorld(tilePosition);
            pos.y += 0.25f;
            transform.position = pos;
            animator.CrossFade(walkNames[data.direction], 0f);
        }
        entities         = GameObject.FindWithTag("EntityList");
        entityController = entities.GetComponent <EntityController>();
        mainCamera       = GameObject.FindWithTag("MainCamera");
        Vector3 camVec = this.transform.position;

        camVec.z = -10;
        mainCamera.transform.position = camVec;
        facing = new string[2];
        maxhp  = 20;
        hp     = data.playerHp;
        if (hp == 0)
        {
            hp = maxhp;
        }
        food = data.food;
        uiController.UpdateBars();
        attack  = 5;
        defense = 5;
        speed   = 1;
        mindmg  = 0;
        maxdmg  = 0;
        armorDR = 0;
        EquipWeapon(data.weapon);
        if (data.armor != null)
        {
            EquipArmor(data.armor);
        }
        saySomething = "";
    }