示例#1
0
    // Use this for initialization
    public virtual void Start()
    {
        // rellenamos las referencias
        rBody = GetComponent <Rigidbody2D>();
        birdSpriteRenderer = GetComponent <SpriteRenderer>();
        cameraController   = Camera.main.GetComponent <CameraController>();

        if (positionOnQeue == 0)
        {
            underPlayerControl = true;
            birdStatus         = BirdStatus.onLaunch;
        }
        else if (positionOnQeue < 0)
        {
            birdStatus         = BirdStatus.onQueue;
            underPlayerControl = false;
        }

        // seteamos un sprite u otro dependiendo del tipo de pajaro
        switch (birdType)
        {
        case (BirdType.red):
            birdSprite = redBirdSprite;
            break;

        case (BirdType.yellow):
            birdSprite = yellowBirdSprite;
            break;

        case (BirdType.black):
            birdSprite = blackBirdSprite;
            pEffector.forceMagnitude = explosionForce;
            break;

        default:
            Debug.LogWarning("No type set for the bird" + transform.name);
            break;
        }

        // cargamos el spriterendere y le cargamos el sprite
        birdSpriteRenderer.sprite = birdSprite;

        // seteamos su posicion inicial
        transform.position = positions[positionOnQeue].transform.position;
        // hacemos que sea kinematic desde un principio
        rBody.isKinematic = true;
    }
示例#2
0
    // Use this for initialization
    void Awake()
    {
        // Check for components
        if (!TryGetComponent(out spriteRenderer))
        {
            Debug.LogError(name + " | missing SpriteRenderer component");
        }
        if (!TryGetComponent(out animator))
        {
            Debug.LogError(name + " | missing Animator component");
        }

        // Get all actions
        actions = GetComponents <Action>();

        // Set reference to bird status
        birdStatus = BirdStatus.Instance;
    }
示例#3
0
    virtual public void FlyToHotPot()
    {
        SpeedY        = FlyHotPotSpeedY;
        FlyHotPotTime = 0;

        CurrentStatus = BirdStatus.BirdStatus_ToHotPot;

        SwordAutoController sac = GameObject.FindObjectOfType <SwordAutoController>();

        if (sac)
        {
            sac.Freeze();
            BirdBase[] birds = GameObject.FindObjectsOfType <BirdBase>();
            foreach (var bird in birds)
            {
                if (bird && bird != this)
                {
                    bird.Freeze();
                }
            }
        }
        Die();
    }
示例#4
0
    virtual public void Move()
    {
        if (CurrentStatus == BirdStatus.BirdStatus_Normal)
        {
            Vector3 move = Vector3.left * SpeedX * Time.deltaTime;
            this.transform.Translate(move);
        }
        else if (CurrentStatus == BirdStatus.BirdStatus_Freeze)
        {
            CurrentFreezeTime += Time.deltaTime;
            SwordAutoController sac = GameObject.FindObjectOfType <SwordAutoController>();
            if (CurrentFreezeTime >= sac.TotalFreezeTime)
            {
                CurrentStatus     = BirdStatus.BirdStatus_Normal;
                CurrentFreezeTime = 0;
            }
        }
        else if (CurrentStatus == BirdStatus.BirdStatus_ToHotPot)
        {
            float GritySpeed = -FlyHotPotAcc * (FlyHotPotTime);

            //SpeedY -= 10  * Time.deltaTime;
            Vector3 move = (SpeedY + GritySpeed) * Time.deltaTime * Vector3.up;
            this.transform.position += move;

            FlyHotPotTime += Time.deltaTime;
        }
        else if (CurrentStatus == BirdStatus.BirdStatus_FlyAway)
        {
            this.transform.Rotate(Vector3.forward, FlyAwayAngleSpeed);

            Vector3 move = Vector3.right * SpeedX * 3 * Time.deltaTime
                           + Vector3.down * SpeedY * Time.deltaTime;
            this.transform.position += move;
            //flyAwayAngle += FlyAwayAngleSpeed * Time.deltaTime;
        }
    }
示例#5
0
 // funcion que se encargara de cambiar el estado del pajaro
 public void SetStatus(BirdStatus bStatus)
 {
     birdStatus = bStatus;
 }
示例#6
0
 // Start is called before the first frame update
 void Start()
 {
     CurrentStatus = BirdStatus.BirdStatus_Normal;
     animator      = this.GetComponent <Animator>();
 }
示例#7
0
 virtual public void Freeze()
 {
     CurrentStatus     = BirdStatus.BirdStatus_Freeze;
     CurrentFreezeTime = 0;
 }
示例#8
0
 virtual public void FlyAway()
 {
     SpeedY        = Random.Range(10, 12);
     SpeedX        = Random.Range(5, 8);
     CurrentStatus = BirdStatus.BirdStatus_FlyAway;
 }