Exemple #1
0
    void Update()
    {
        if (LerpAnimation != null && !LerpAnimation.IsFinished())
        {
            this.transform.position = LerpAnimation.Eval();
        }
        else if (isSelected)
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (colCardPlan.Raycast(ray, out hit, 100f))
            {
                if (vecInitialSelection == Vector3.zero)
                    vecInitialSelection = hit.point;

                Vector3 cardPosition = LerpAnimation.EndValue + hit.point - vecInitialSelection + new Vector3(0,0.3f,0f);

                Quaternion quat = Quaternion.AngleAxis(90, Vector3.up);
                Vector3 vect = quat * this.transform.up;

                ray = new Ray(cardPosition, vect);

                Debug.DrawRay(ray.origin, ray.direction);

                NextContinentCard = null;

                foreach (BoxCollider colContinentCard in listColContinentCard)
                {
                    if (colContinentCard.Raycast(ray, out hit, 100f))
                    {
                        NextContinentCard = colContinentCard.gameObject.GetComponent<ContinentCard>();

                        colContinentCard.gameObject.renderer.material.color = Color.yellow;
                    }
                    else
                    {
                        colContinentCard.gameObject.renderer.material.color = Color.white;
                    }
                }

                //if (cardPosition.y >= 0.36f && cardPosition.y <= 1.05f && cardPosition.x >= -2f && cardPosition.x <= 1.9f)

                //if (NextContinentCard == null)
                    this.transform.position = cardPosition;

            }
        }
    }
Exemple #2
0
    public void OnMouseUp()
    {
        if (Game.GameState == GameState.PickCardInHand)
        {
            isSelected = false;
            vecInitialSelection = Vector3.zero;

            if (NextContinentCard != null)
            {
                //---> Déplacement d'une carte par dessus une autre carte
                if (NextContinentCard.Card != null)
                {
                    //---> Déplacement d'une carte issue de la main sur une carte déja posée
                    if (ContinentCard == null)
                    {
                        Game.Player.ListCardInHand.Add(NextContinentCard.Card);
                        Game.Player.SortPileInHand(false);

                        NextContinentCard.Card.ContinentCard = null;
                    }
                    //---> Déplacement d'une carte déja posée sur une carte déja posée
                    else
                    {
                        NextContinentCard.Card.LerpAnimation = new LerpVector3(NextContinentCard.Card.transform.position, Tools.TransYVector(ContinentCard.transform.position), false, false, 0.2f);

                        NextContinentCard.Card.ContinentCard = ContinentCard;
                        ContinentCard.Card = NextContinentCard.Card;
                    }
                }
                else if (ContinentCard != null)
                {
                    ContinentCard.Card = null;
                }

                LerpAnimation = new LerpVector3(this.transform.position, new Vector3(NextContinentCard.transform.position.x,NextContinentCard.transform.position.y+0.01f,NextContinentCard.transform.position.z), false, false, 0.2f);

                NextContinentCard.Card = this;
            }
            else
            {
                if (ContinentCard != null)
                    ContinentCard.Card = null;

                Game.Player.ListCardInHand.Add(this);

                this.LerpAnimation.StartValue = this.transform.position;

                Game.Player.SortPileInHand(false);
            }

            ContinentCard = NextContinentCard;
            NextContinentCard = null;
        }
    }
Exemple #3
0
 void Start()
 {
     continentCard = (ContinentCard)this.GetComponentInChildren(typeof(ContinentCard));
     initialLocation = this.transform.position;
 }