Exemplo n.º 1
0
 public virtual void Call(Vector2Int pos, playerID spCaster)
 {
     castPos = pos;
     caster  = spCaster;
     Clock.Instance.OnTick += SBehaviour;
     active = true;
 }
Exemplo n.º 2
0
    public void SelectSprite(TileSpites spriteToDisplay, playerID palyer)
    {
        switch (spriteToDisplay)
        {
        case TileSpites.shot:
            if (palyer == playerID.player1)
            {
                gameObject.GetComponent <Image>().sprite = p1Shot;
            }
            else
            {
                gameObject.GetComponent <Image>().sprite = p2Shot;
            }
            break;

        case TileSpites.player:
            if (palyer == playerID.player1)
            {
                gameObject.GetComponent <Image>().sprite = player1;
            }
            else
            {
                gameObject.GetComponent <Image>().sprite = player2;
            }
            break;
        }
    }
 public override void Call(Vector2Int pos, playerID spCaster)        
 {
     caster = spCaster;
     castPos = pos;
     generateStartingDamageZone();
     Clock.Instance.OnTick += SBehaviour;
     active = true;
 }
 public Player(Vector2Int spawnPos, playerID iD)
 {
     myID            = iD;
     currentHp       = initialHp;
     alive           = true;
     currentPos      = spawnPos;
     currentSpecials = new List <ISpecial>();
 }
Exemplo n.º 5
0
    IEnumerator InitMiniMapSprite()
    {
        playerID playerIDscr = GameObject.FindGameObjectWithTag("Player").GetComponent <playerID>();

        while (playerIDscr.ID == 0)
        {
            yield return(new WaitForSeconds(0.5f));

            TagMiniMapSprite_PlayerNumber(PlayerLocT.gameObject, GameObject.FindGameObjectWithTag("Player"));
        }
    }
Exemplo n.º 6
0
    // Update is called once per frame
    private void OnCollisionEnter(Collision collision)
    {
        return;

        if (cp.lostPartDelay > 0)
        {
            return;
        }

        if (collision.gameObject.GetComponent <floating_part>())
        {
            return;
        }

        playerID pID = collision.gameObject.GetComponentInParent <playerID>();

        if (!pID)
        {
            if (collision.gameObject.tag != "ground" && (collision.impulse.magnitude > partConfig.impulseToLosePartNonPlayer))
            {
                cp.lose_random_part(collision.impulse);
            }
            return;
        }

        if (pID.p == playerID)
        {
            return;
        }

        //Debug.Log("car_parts collision impulse: " + collision.impulse.magnitude);
        if (collision.impulse.magnitude > partConfig.impulseToLosePart)
        {
            Vector3 selfVelocity = this.GetComponent <Rigidbody>().velocity;
            Vector3 otherVelcity = collision.gameObject.GetComponent <Rigidbody>().velocity;
            Vector3 impulse      = collision.impulse;
            float   selfDot      = Vector3.Dot(selfVelocity.normalized, impulse);
            float   otherDot     = Vector3.Dot(otherVelcity.normalized, impulse);

            if (selfDot < otherDot) //other car suffers
            {
                //float upper_bound = Mathf.Pow(0.75f,cp.partCount(playerID, part.bumper));
                //float random_roll = Random.Range(0, 1);

                collision.gameObject.GetComponentInParent <car_parts>().lose_random_part(collision.impulse);
            }
            else //you suffer
            {
                //cp.lose_random_part(collision.impulse);
            }
        }
    }
Exemplo n.º 7
0
    public void doTurn()
    {
        switch (currentPlayer)
        {
        case playerID.player1:
            currentPlayer = playerID.player2;
            Player1UI.SetActive(false);
            Player2UI.SetActive(true);
            break;

        case playerID.player2:
            currentPlayer = playerID.player1;
            Player1UI.SetActive(true);
            Player2UI.SetActive(false);
            break;

        default:
            break;
        }

        selectedShip.GetComponent <TurnbasedSpaceship>().isSelected = false;
        selectedShip = null;
        doingTurn    = false;
    }
Exemplo n.º 8
0
    private void OnCollisionEnter(Collision collision)
    {
        if (lostPartDelay > 0)
        {
            return;
        }

        if (collision.gameObject.GetComponent <floating_part>())
        {
            return;
        }

        playerID pID = collision.gameObject.GetComponentInParent <playerID>();

        if (!pID)
        {
            if (collision.gameObject.tag != "ground" && (collision.impulse.magnitude > partConfig.impulseToLosePartNonPlayer))
            {
                lose_random_part(collision.impulse);
            }
            return;
        }

        if (pID.p == playerID)
        {
            return;
        }

        //Debug.Log("car_parts collision impulse: " + collision.impulse.magnitude);
        if (collision.impulse.magnitude > partConfig.impulseToLosePart)
        {
            Vector3 selfVelocity = this.GetComponent <Rigidbody>().velocity;
            Vector3 impulse      = collision.impulse;

            float selfDot = Mathf.Abs(Vector3.Dot(transform.forward, impulse.normalized));

            const float dotThreshold  = 0.5f;
            const float veloThreshold = 9f;
            if (selfDot < dotThreshold || selfVelocity.magnitude < veloThreshold)   // always lose a part if your dot or velo is under a threshold
            {
                const int maxPartsLost = 3;
                int       partsLost    = Random.Range(1, maxPartsLost + 1);
                for (int i = 0; i < partsLost; i++)
                {
                    lose_random_part(collision.impulse);
                }
            }
            else
            {
                int protects = my_parts[playerID].val[(int)part.bumper] + 1;
                for (int i = 0; i < protects; i++)
                {
                    if (Random.Range(0f, 1f) > 0.5f)
                    {
                        return;
                    }
                }

                if (my_parts[playerID].val[(int)part.bumper] > 0)
                {
                    lose_part(part.bumper, collision.impulse);
                }
                else
                {
                    lose_random_part(collision.impulse);
                }
            }
        }
    }
Exemplo n.º 9
0
 players.Add(new Player(playerID, cards));