예제 #1
0
    public void Build()
    {
        GameObject building = null;

        if (ToBuild == ThingToBuild.tower)
        {
            //build tower
            building = GameManagerScript.Get.buildings.Tower;
        }
        else if (ToBuild == ThingToBuild.quarry)
        {
            building = GameManagerScript.Get.buildings.Quarry;
        }
        else if (ToBuild == ThingToBuild.sawmill)
        {
            building = GameManagerScript.Get.buildings.Sawmill;
        }

        if (CanYouAffordIt(building))
        {
            PosStamp.obj.GetComponent <TileScript>().Disable();
            Instantiate(building, PosStamp.pos + PosStamp.offset, Quaternion.identity, GameObject.Find("Tilemap").transform);
            PlayerScript.AddResource(ResourceType.gold, -building.GetComponent <BuildingScript>().Price[0]);
            PlayerScript.AddResource(ResourceType.wood, -building.GetComponent <BuildingScript>().Price[1]);
            PlayerScript.AddResource(ResourceType.stone, -building.GetComponent <BuildingScript>().Price[2]);
        }
        ItsPanel.SetActive(false);
    }
예제 #2
0
    public IEnumerator WaitForClick(GameObject building)
    {
        Debug.Log("corotine");
        GameManagerScript.ScreenFree = false;
        yield return(new WaitForSecondsRealtime(0.1f));

        while (true)
        {
            Debug.Log("checking mouse");
            if (Input.GetMouseButton(0))
            {
                Debug.Log("okokokokokkokokokokokokokok");
                Debug.Log(Vector3.Distance(Camera.main.ScreenToWorldPoint(Input.mousePosition), PosStamp.obj.transform.position));
                if (Vector3.Distance(Camera.main.ScreenToWorldPoint(Input.mousePosition), PosStamp.obj.transform.position) < 15.0f)
                {
                    Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    Instantiate(building, new Vector3(pos.x, pos.y, 0), Quaternion.identity, GameObject.Find("Tilemap").transform);
                    PlayerScript.AddResource(ResourceType.gold, -building.GetComponent <BuildingScript>().Price[0]);
                    PlayerScript.AddResource(ResourceType.wood, -building.GetComponent <BuildingScript>().Price[1]);
                    PlayerScript.AddResource(ResourceType.stone, -building.GetComponent <BuildingScript>().Price[2]);
                    PosStamp.obj.GetComponent <TowerScript>().upgrades.Add(building.GetComponent <BuildingScript>().upgrade);
                }
                GameManagerScript.ScreenFree = true;
                ItsPanel.SetActive(false);
                break;
            }

            yield return(null);
        }
    }
예제 #3
0
 // Update is called once per frame
 void Update()
 {
     if (Time.time - resourceTimeStamp >= TimeInterval)
     {
         resourceTimeStamp = Time.time;
         PlayerScript.AddResource(Resource, ResourceQuantity);
     }
 }
예제 #4
0
    public void InflictDamage(float damage)
    {
        Health -= damage;

        if (Health <= 0f)
        {
            PlayerScript.AddResource(ResourceType.gold, 10);
            GameManagerScript.Get.enemyList.Remove(gameObject.transform);
            gameObject.SetActive(false);
        }
    }
예제 #5
0
    // Update is called once per frame
    void Update()
    {
        MovementSpeed *= GameManagerScript.EnemySpeedVaryfier;

        if (stop)
        {
            //attacking animation
            if (Time.time - dissapearTimeStamp >= dissapearTime)
            {
                PlayerScript.AddResource(ResourceType.life, -1);
                Destroy(gameObject);
            }

            return;
        }

        Vector3 directionVector = new Vector3(GameManagerScript.Get.currentPath[pathNumber].Waypoints[waypointIterator].transform.position.x - transform.position.x + offset,
                                              GameManagerScript.Get.currentPath[pathNumber].Waypoints[waypointIterator].transform.position.y - transform.position.y, 0);


        transform.Translate(directionVector.normalized * MovementSpeed * Time.deltaTime);

        if (directionVector.x > 0.1f)
        {
            ren.sprite = spriteSide;
        }
        else if (directionVector.x < -.1f)
        {
            ren.sprite           = defaultSprite;
            transform.localScale = new Vector3(transform.localScale.x * -1f, transform.localScale.y, transform.localScale.z);
        }
        else
        {
            ren.sprite = defaultSprite;
        }

        dist = Vector2.Distance(transform.position, GameManagerScript.Get.currentPath[pathNumber].Waypoints[waypointIterator].transform.position);
        if (dist <= 1f)
        {
            if (waypointIterator < GameManagerScript.Get.currentPath[pathNumber].Waypoints.Length - 1)
            {
                waypointIterator++;
            }
            else
            {
                stop = true;
                dissapearTimeStamp = Time.time;
                //Destroy(gameObject);
                //return;
            }
        }
    }
예제 #6
0
    // Update is called once per frame
    void Update()
    {
        if (Time.time - shootingTimeStamp >= shootingTimeInterval)
        {
            shootingTimeStamp = Time.time;
            attackCounter     = 0;
            CheckRange();
        }

        if (upgrades.Count > listCount)
        {
            Debug.Log(upgrades[listCount]);
            DealTheDeal(upgrades[listCount]);
            listCount++;
        }

        if (giveGold && (Time.time - goldTimeStamp >= goldInterval))
        {
            PlayerScript.AddResource(ResourceType.gold, 5);
            goldTimeStamp = Time.time;
        }
    }