Пример #1
0
 public void cardClick(Card c)
 {
     if (isMulligan)
     {
         if (toMulligan.Contains(c))
         {
             c.setSelection(false);
             toMulligan.Remove(c);
         }
         else
         {
             c.setSelection(true);
             toMulligan.Add(c);
         }
     }
     else if (myTurn)
     {
         int cost = c.resourceCost;
         //Debug.Log(cost);
         if (c == cardCurrent)
         {
             state = targetState.Free;
             setTargetCard(null);
         }
         else if (cost <= currentResources && cost <= st.getStat(StatType.resourceSpend))
         {
             state = targetState.Card;
             //setTargetAbility(null);
             setTargetUnit(null);
             setTargetCard(c);
         }
     }
 }
Пример #2
0
    private void SwitchToIdle()
    {
        isCurrently = targetState.idle;
        targetAnimator.SetBool("isIdling", true);
        targetAnimator.SetBool("isWalking", false);
        targetAnimator.SetBool("isDying", false);

        totalIdleTime = 0f;
    }
Пример #3
0
 public void setTurn(bool isTurn)
 {
     myTurn = isTurn;
     if (!isTurn)
     {
         //setTargetAbility(null);
         setTargetUnit(null);
         setTargetCard(null);
         state = targetState.Free;
     }
     UIturn.setTurn(isTurn);
 }
Пример #4
0
 // Start is called before the first frame update
 void Start()
 {
     isCurrently    = targetState.idle;
     speed          = 10;
     agent          = GetComponent <NavMeshAgent>();
     agent.speed    = speed;
     walkPoints     = GameObject.FindGameObjectsWithTag("Walk Point");
     nextPoint      = walkPoints[0];
     idleTime       = 3;
     targetAnimator = GetComponent <Animator>();
     targetAnimator.SetBool("isIdling", true);
     targetAnimator.SetBool("isWalking", false);
     targetAnimator.SetBool("isDying", false);
 }
Пример #5
0
 public void abilityClick(OrdSqUI o)
 {
     if (myTurn)
     {
         int cost = o.ability.resourceCost;
         //Debug.Log(cost);
         if (o == abilityCurrent)
         {
             state = targetState.Unit;
             setTargetAbility(null);
         }
         else if (cost <= currentResources && o.ability.caster.canCast)
         {
             state = targetState.Ability;
             //setTargetUnit(null);
             setTargetCard(null);
             setTargetAbility(o);
         }
     }
 }
Пример #6
0
 internal void Walking()
 {
     if (isCurrently != targetState.walking)
     {
         nextPoint = walkPoints[Random.Range(0, walkPoints.Length)];
         if (!nextPoint.activeSelf)
         {
             Walking();
         }
         else
         {
             nextPoint.SetActive(false);
             agent.SetDestination(new Vector3(nextPoint.transform.position.x, 0, nextPoint.transform.position.z));
             isCurrently = targetState.walking;
             targetAnimator.SetBool("isIdling", false);
             targetAnimator.SetBool("isWalking", true);
             targetAnimator.SetBool("isDying", false);
         }
     }
 }
Пример #7
0
    // Update is called once per frame
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }
        inp.updateInputs();
        if (myTurn)
        {
            if (inp.endTurn)
            {
                CmdEndTurn();
            }
            else if (inp.click && inp.target)
            {
                //Debug.Log(inp.target.name);
                Unit u;
                switch (state)
                {
                case targetState.Free:
                    u = inp.target.getOccupant();
                    if (u && u.teamIndex == teamIndex)
                    {
                        setTargetUnit(u);
                        state = targetState.Unit;
                        //Debug.Log("Unit");
                    }
                    break;

                case targetState.Unit:
                    //Debug.Log("Move");
                    u = inp.target.getOccupant();
                    if (u)
                    {
                        //gm.attack(unitCurrent, inp.target);
                        if (u.teamIndex == teamIndex)
                        {
                            if (u == unitCurrent)
                            {
                                state = targetState.Free;
                                setTargetUnit(null);
                            }
                            else
                            {
                                setTargetUnit(u);
                            }
                        }
                        else
                        {
                            CmdPawnAttack(unitCurrent.netId, inp.target.netId);
                            state = targetState.Free;
                            setTargetUnit(null);
                        }
                    }
                    else
                    {
                        if (inp.target.isWalk || unitCurrent.type == Unit.unitType.flying)
                        {
                            //gm.move(unitCurrent, inp.target);
                            CmdPawnMove(unitCurrent.netId, inp.target.netId);
                            state = targetState.Free;
                            setTargetUnit(null);
                        }
                    }


                    break;

                case targetState.Card:
                    //if (!cardCurrent)
                    //{

                    //}
                    if (cardCurrent.GetComponent <Targeting>().evaluate(inp.target, teamIndex))
                    {
                        CmdCardPlay(cardCurrent.netId, inp.target.netId);
                        state = targetState.Free;
                        setTargetCard(null);
                    }
                    //else
                    //{
                    //     state = targetState.Free;
                    //     setTargetCard(null);
                    // }
                    break;

                case targetState.Ability:
                    if (abilityCurrent.ability.GetComponent <Targeting>().evaluate(inp.target, teamIndex, unitCurrent.loc))
                    {
                        CmdAbilityCast(abilityCurrent.ability.GetComponent <NetworkIdentity>().netId, inp.target.netId);
                        state = targetState.Unit;
                        setTargetAbility(null);
                    }

                    break;

                default:
                    Debug.LogError("not implemented");
                    break;
                }
            }
            else if (inp.cancel)
            {
                switch (state)
                {
                case targetState.Free:
                    //do nothing
                    break;

                case targetState.Unit:
                    state = targetState.Free;
                    setTargetUnit(null);
                    break;

                case targetState.Card:
                    state = targetState.Free;
                    setTargetCard(null);
                    break;

                case targetState.Ability:
                    state = targetState.Unit;
                    setTargetAbility(null);
                    break;
                }
            }
        }

        //Inspect unit on board
        if (true /*!myTurn || state == targetState.Free*/)
        {
            if (inp.target && inp.target.getOccupant())
            {
                if (hoverUnitCurrent && hoverUnitCurrent == inp.target.getOccupant())
                {
                    if (!inspecting)
                    {
                        hoverUnitTime += Time.deltaTime;
                        if (hoverUnitTime > GameConstants.hoverInspectTime)
                        {
                            inspecting = true;
                            inspect.inspect(hoverUnitCurrent.gameObject, CardInspector.inspectType.cardmaker, 3);
                        }
                    }
                }
                else
                {
                    if (inspecting)
                    {
                        inspecting = false;
                        inspect.uninspect(hoverUnitCurrent.gameObject);
                    }
                    hoverUnitCurrent = inp.target.getOccupant();
                    hoverUnitTime    = 0;
                }
            }
            else
            {
                if (inspecting)
                {
                    inspecting = false;
                    inspect.uninspect(hoverUnitCurrent.gameObject);
                }
                if (hoverUnitCurrent)
                {
                    hoverUnitCurrent = null;
                }
            }
        }

        Vector3 camForward = transform.GetChild(0).forward;


        if (gm.viewPipe.isFixating)
        {
            transform.position = gm.viewPipe.fixation - camForward * Mathf.Abs((transform.position.y - gm.viewPipe.fixation.y) / camForward.y);
        }
        else
        {
            transform.position += (transform.right * inp.pan.x + transform.forward * inp.pan.y) * transform.position.y;
        }

        transform.position += camForward * inp.zoom;
    }