예제 #1
0
        public override void Resume()
        {
            GResource.LoadTextures();

            var imageFon = new GImage(Game);

            imageFon.SetTexture(GResource.game_fon);
            imageFon.SetWidth(Game.GetWindowWidth());
            imageFon.SetHeight(Game.GetWindowHeight());
            imageFon.SetX(Game.GetWindowWidth() / 2);
            imageFon.SetY(Game.GetWindowHeight() / 2);
            AddElement(imageFon);

            tree = new ChristmasTree(Game);
            tree.GenerateDecorations(3);

            train = new Train(Game, GResource.train);
            train.Initialize(Game.GetWindowWidth() / 2, 65, 90, 30);
            train.SetChristmasTree(tree);

            cat = new Cat(Game, Game.GetWindowWidth() / 2, Game.GetWindowHeight() / 2, 50, 50);
            cat.AddTextures(GResource.lcat, Cat.STATE.LEFT);
            cat.AddTextures(GResource.rcat, Cat.STATE.RIGHT);
            cat.Bump();
            cat.SetChristmasTree(tree);
            //	AddElement(imageCat);
        }
예제 #2
0
    /// <summary>
    /// Page GameObject Name 必须和LuaLogic的文件名一致,避免不必要的配置
    /// </summary>
    /// <param name="pagePath"></param>
    /// <param name="param"></param>
    public void Show(string pagePath, object param = null)
    {
        if (!cachePagePool.ContainsKey(pagePath))
        {
            new Promise <LoadOperation>((s, j) =>
            {
                LoadOperation loader = GResource.LoadAssetAsync(pagePath);
                loader.OnFinish     += s;
                AppInter.StartCoroutine(loader);
            }).Then((loader) =>
            {
                GameObject prefab = loader.GetAsset <GameObject>();

                GameObject gObj = GameObject.Instantiate(prefab);
                gObj.name       = Path.GetFileNameWithoutExtension(pagePath);

                LuaPageBehaviour pageBehaviour = gObj.AddComponent <LuaPageBehaviour>();
                UIPage page = new UIPage(pageBehaviour, pagePath);

                //缓存记录
                cachePagePool.Add(pagePath, page);
                showUIPage(page, param);
            }).Catch((e) =>
            {
                Debug.LogError("加载Page异常! Path:" + pagePath);
                Debug.LogException(e);
            });
        }
        else
        {
            UIPage page = cachePagePool[pagePath];
            showUIPage(page, param);
        }
    }
예제 #3
0
        public override void Resume()
        {
            GResource.LoadTextures();

            imgLMD = new GImage(Game);
            imgLMD.SetTexture(GResource.game_fon);
            imgLMD.SetWidth(250);
            imgLMD.SetHeight(200);
            imgLMD.SetX(Game.GetWindowWidth() / 2);
            imgLMD.SetY(Game.GetWindowHeight() / 2 + 100);
            AddElement(imgLMD);

            CircleButton but = new CircleButton(Game);

            but.onClick += ScreenStart_onClick;
            but.SetX(Game.GetWindowWidth() / 2);
            but.SetY(150);
            but.SetRadius(80);
            but.SetImage(GImage.LoadTexture(@"C:\Users\User\Desktop\WarBugs\button_play.png"));

            GameFramewerk.UI.Animations.AnimationScale anim = new GameFramewerk.UI.Animations.AnimationScale();
            anim.Initialize(but.GetWidth(), but.GetHeight(), but.GetWidth() + 20, but.GetHeight() + 20, 4, 4, but);

            AddElement(but);
        }
예제 #4
0
 public void AddItem(GResource resource)
 {
     if (resource == null)
     {
         throw new NullReferenceException();
     }
     items.Add(resource);
 }
예제 #5
0
    public ResourceType GetResourcesType(Vector2Int location)
    {
        GResource result = (GResource)chesses.Find(x => (location == x.location && (x is GResource)));

        if (result)
        {
            return(result.type);
        }
        else
        {
            return(ResourceType.None);
        }
    }
예제 #6
0
 protected void Start()
 {
     ownResource = GridManager.instance.GetResources(location);
     if (ownResource)
     {
         ownResource.GetComponentInChildren <Renderer>().enabled = false;
     }
     RefreshMesh();
     RefreshText();
     Instantiate(PrefabManager.instance.buildingParticle,
                 transform.position + PrefabManager.instance.buildingParticle.transform.position,
                 PrefabManager.instance.buildingParticle.transform.rotation);
 }
예제 #7
0
        public void RemoveItem(GResource resource)
        {
            int indexToRemove = -1;

            foreach (GResource it in items)
            {
                indexToRemove++;
                if (resource == it)
                {
                    break;
                }
            }
            if (indexToRemove > -1)
            {
                items.RemoveAt(indexToRemove);
                return;
            }
            throw new NotInInventory();
        }
예제 #8
0
 //void FixedUpdate()
 //{    //取消弹性
 //    this.GetComponent<Rigidbody>().velocity = new Vector3(0, 0, 0);
 //}
 private void Update()
 {
     ////postion锁定
     //foreach (Transform _transform in GetAllChilds())
     //{
     //    _transform.localPosition = new Vector3(0, _transform.localPosition.y, 0);
     //}
     if (playerInput.Dis > 0.02f)
     {
         //旋转
         Vector3 targetForward = Vector3.Slerp(this.transform.forward,
                                               playerInput.Dright * DirTran.right + playerInput.Dup * DirTran.forward, 0.4f);
         this.transform.forward = targetForward;
         //位移
         velocity = this.transform.forward * runSpeed;
         this.transform.position += velocity * Time.deltaTime;
         //location更新
         location = GridManager.instance.Vector3ToVector2Int(this.transform.position);
         //Direction朝向更新
         if (this.transform.eulerAngles.y >= 315 || this.transform.eulerAngles.y < 45)
         {
             direction = Direction.up;
         }
         else if (this.transform.eulerAngles.y >= 45 && this.transform.eulerAngles.y < 135)
         {
             direction = Direction.right;
         }
         else if (this.transform.eulerAngles.y >= 135 && this.transform.eulerAngles.y < 225)
         {
             direction = Direction.down;
         }
         else if (this.transform.eulerAngles.y >= 225 && this.transform.eulerAngles.y < 315)
         {
             direction = Direction.left;
         }
     }
     HighLightHandle();
     if (Input.GetKeyDown(playerInput.KeyPickUp))
     {
         GTower targetTower = GridManager.instance.GetTower(GetSelectLocation());
         if (targetTower != null)
         {
             targetTower.BePickUp(this);
         }
         else
         {
             GResource targetResource = GridManager.instance.GetResources(GetSelectLocation());
             if (targetResource != null)
             {
                 targetResource.BePickUp(this);
             }
         }
     }
     if (Input.GetKeyDown(playerInput.KeyPutDown))
     {
         if (conveyObject != null)
         {
             Putdown();
         }
     }
     if (Input.GetKeyDown(playerInput.KeyRotation))
     {
         Vector2Int select = GetSelectLocation();
         Debug.Log(select);
         GChess chess = GridManager.instance.GetTower(select);
         if (chess)
         {
             Debug.Log(chess);
             if (chess.chessType == ChessType.shooterTower)
             {
                 chess.GetComponent <GShooterTower>().direction = chess.GetComponent <GShooterTower>().direction.ClockwiseNext();
             }
         }
     }
     //更新动画
     animator.SetBool("isConvey", conveyObject != null);
 }
예제 #9
0
 private void GiveToPatient(GResource resource)
 {
     patient.Inventory.AddItem(resource);
 }