Example #1
0
    public void BuildCastle2D(BuildingInfo info)
    {
        GameObject a = Instantiate(preToy) as GameObject;

        a.GetComponent <SpriteRenderer>().sprite = Data.inst.topList[info.buildingCode];
        a.GetComponent <SpriteRenderer>().color  = Data.inst.colorList[info.colorCode];
        a.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite = Data.inst.backList[info.buildingCode];
        a.transform.SetParent(buildingList);
        a.transform.localPosition = GameManager2D.XYtoVector2(info.x, info.y);
        a.transform.localScale    = Vector3.one * Data.inst.scale;
    }
Example #2
0
    protected override void UpdatePostion()
    {
        go += Time.deltaTime * GameManager.ARMY_SPEED * GameManager.inst.gameSpeed;
        Vector2 pos = Vector2.MoveTowards(fromCity.GetPostion(), toCity.GetPostion(), go);

        transform.position = GameManager2D.XYtoVector2((int)pos.x, (int)pos.y);

        /*
         * distance=Vector3.Distance(transform.position, toCity.transform.position);
         * if(distance>0.2f)
         * {
         *  go+=Time.deltaTime*GameManager2D.ARMY_SPEED * GameManager2D.inst.gameSpeed;
         *  transform.position =Vector2.MoveTowards(startPos,endPos,go);
         * }
         */
    }