コード例 #1
0
    private void OnMouseDown()
    {
        if (canWalkTo)
        {
            if (currentStepingGameTool != null)
            {
                game.SetToolUI(currentStepingGameTool, currentStepingGameTool.GetComponentInParent <Loading>(), false);
            }
            game.SetToolUI(game.GetClickedTile().currentStepingGameTool, game.GetClickedTile().currentStepingGameTool.GetComponentInParent <Loading>(), false);
            game.MoveTo(GetComponent <Tile>());
        }
        else if (!canWalkTo && canBeClicked && game.GetClickedTile() != this)
        {
            if (gameToolResized)
            {
                currentStepingGameTool.gameObject.transform.localScale -= currentStepingGameTool.GetResizeFactor();
                gameToolResized = false;
            }

            game.SetClickedTile(GetComponent <Tile>());
            game.SetToolUI(currentStepingGameTool, currentStepingGameTool.GetComponentInParent <Loading>(), true);
        }
        else if (!canWalkTo && canBeClicked && game.GetClickedTile() == this)
        {
            game.ResetClickedTile();
            game.SetToolUI(currentStepingGameTool, currentStepingGameTool.GetComponentInParent <Loading>(), false);
        }
    }
コード例 #2
0
 private void OnMouseDown()
 {
     if (Loaded != null && Loaded.GetToolsPlayerId() == game.GetTurnPlayerID())
     {
         if (Loader.GetComponentInParent <Loading>().GetReadyToUnloadTool() == null)
         {
             Loader.GetComponentInParent <Loading>().SetReadyToUnloadTool(Loader, Loaded);
         }
         else
         {
             if (Loader == game.GetLoader())
             {
                 if (Loaded.GetComponentInParent <Loading>().CanBeLoadTo(Loader.GetComponentInParent <Loading>().GetReadyToUnloadTool()))
                 {
                     Loader.GetComponentInParent <Loading>().LoadToolOnReadyToUnloadTool(Loaded);
                     game.SetClickedLoadedTool(Loader, Loader.GetComponentInParent <Loading>().GetReadyToUnloadTool());
                 }
             }
             else
             {
                 Loader.GetComponentInParent <Loading>().SetReadyToUnloadTool(Loader, Loaded);
             }
         }
     }
 }
コード例 #3
0
    public void Load(GameTool gameTool, Tile loadFrom = null)
    {
        Debug.Log(gameTool.transform.position);
        if (gameTool.GetName() != "Flag")
        {
            loadedGameTools.Add(gameTool);

            if (loadFrom != null)
            {
                loadFrom.SetCurrentStepingGameTool(null);
            }
            Debug.Log(gameTool.transform.position);
            foreach (Transform child in gameTool.gameObject.transform.parent)
            {
                child.gameObject.transform.localScale = Vector3.zero;
            }
            //gameTool.gameObject.transform.parent.position = transform.parent.position;
            //gameTool.gameObject.transform.parent.parent = transform.parent;
            gameTool.GetComponentInParent <Loading>().SetLoader(GetComponentInParent <GameTool>());
            Debug.Log(gameTool.transform.position);
            game.PassTurn();
        }
        else
        {
            loadedGameTools.Add(gameTool);
            if (loadFrom != null)
            {
                loadFrom.SetCurrentStepingGameTool(null);
            }

            foreach (Transform child in gameTool.gameObject.transform.parent)
            {
                child.gameObject.transform.localScale = Vector3.zero;
            }
            //gameTool.gameObject.transform.parent.position = transform.parent.position;
            //gameTool.gameObject.transform.parent.parent = transform.parent;
            HasFlag = true;
        }
        Debug.Log(gameTool.transform.position);
    }
コード例 #4
0
    public bool CanBeLoadTo(GameTool gameTool)
    {
        if (gameTool.GetName() == "Flag")
        {
            return(false);
        }
        if (!canBeLoaded || gameTool.transform.parent.tag == "Soldier")

        {
            return(false);
        }
        else
        {
            if (loadedGameTools.Count + 1 + gameTool.GetComponentInParent <Loading>().loadedGameTools.Count <= gameTool.GetComponentInParent <Loading>().loadCapability)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
    }
コード例 #5
0
 public void LoadToolOnReadyToUnloadTool(GameTool gametool)
 {
     ReadyToUnloadTool.GetComponentInParent <Loading>().Load(gametool);
 }