public GameObject dropSheep()
    {
        if (sheepPickedup.Count == 0)
        {
            return(null);
        }

        GameObject droppedSheep = sheepPickedup.Pop();

        SheepMovement droppedSheep_movement = droppedSheep.GetComponentInChildren <SheepMovement>();
        Animator      droppedSheep_animator = droppedSheep.GetComponentInChildren <Animator>();
        Rigidbody     droppedSheep_rb       = droppedSheep.GetComponent <Rigidbody>();

        // set state to available and anim state to iddle
        droppedSheep_movement.setAvailable();
        IAnimState animState = new Iddle(ref droppedSheep_animator);

        droppedSheep_movement.SetAnimState(animState);

        sheepCollideWithBases(droppedSheep);
        changePlayerSpeed();

        droppedSheep_rb.velocity   = Vector3.zero;
        droppedSheep_rb.useGravity = true;

        SendDroppedSheepMessage(droppedSheep.transform.name, droppedSheep_movement.getState(), droppedSheep_animator.GetInteger("Index"));

        return(droppedSheep);
    }
    private void pickupSheep()
    {
        GameObject sheepToPickup = sheepColliding[0];

        sheepColliding.RemoveAt(0);

        SheepMovement sheepToPickup_movement = sheepToPickup.GetComponentInChildren <SheepMovement>();
        Animator      sheepToPickup_animator = sheepToPickup.GetComponentInChildren <Animator>();
        Rigidbody     sheepToPickup_rb       = sheepToPickup.GetComponent <Rigidbody>();

        // set state to unavaiable and anim state to ball
        sheepToPickup_movement.setUnavailable();
        IAnimState animState = new Ball(ref sheepToPickup_animator);

        sheepToPickup_movement.SetAnimState(animState);

        sheepGhostBases(sheepToPickup);

        sheepToPickup_rb.velocity        = Vector3.zero;
        sheepToPickup_rb.angularVelocity = Vector3.zero;
        sheepToPickup_rb.useGravity      = false;

        sheepPickedup.Push(sheepToPickup);
        changePlayerSpeed();
    }
    public void processDroppedSheepMessage(DroppedSheepMessage _msg)
    {
        GameObject sheep = GameObject.Find(_msg.sheepName);

        if (sheep != null)
        {
            SheepMovement sheep_movement = sheep.GetComponent <SheepMovement>();
            Rigidbody     sheep_rb       = sheep.GetComponent <Rigidbody>();

            sheep_rb.velocity   = Vector3.zero;
            sheep_rb.useGravity = true;

            sheep_movement.setPickedUpBy("");
            sheep_movement.setState(_msg.sheepState);
        }
    }
    public void processLandSheepMessage(LandSheepMessage _msg)
    {
        GameObject sheep = GameObject.Find(_msg.sheepName);

        if (sheep != null)
        {
            SheepMovement sheep_movement = sheep.GetComponent <SheepMovement>();
            Animator      sheep_animator = sheep.GetComponentInChildren <Animator>();

            // set state to available and anim state to iddle
            sheep_movement.setAvailable();
            IAnimState animState = new Iddle(ref sheep_animator);
            sheep_movement.SetAnimState(animState);

            // ignoreCollisionWithBases(sheep, true);
            ignoreCollisionWithPlayers(sheep, true);
        }
    }
    public void processPickedUpSheepMessage(PickedUpSheepMessage _msg)
    {
        GameObject sheep = GameObject.Find(_msg.sheepName);

        if (sheep != null)
        {
            SheepMovement sheep_movement = sheep.GetComponent <SheepMovement>();
            Rigidbody     sheep_rb       = sheep.GetComponent <Rigidbody>();

            sheep_rb.velocity        = Vector3.zero;
            sheep_rb.angularVelocity = Vector3.zero;
            sheep_rb.useGravity      = false;

            sheep_movement.setPickedUpBy(_msg.playerName);
            sheep_movement.setState(_msg.sheepState);
            sheep_movement.localMove(_msg.sheepPosition, _msg.sheepRotation, _msg.time, _msg.sheepAnimation);
        }
    }
Ejemplo n.º 6
0
    void Start()
    {
        sheepScript = GetComponent <Sheep>();
        gmScript    = GameObject.Find("_manager").GetComponent <GameManager>();
        moveScript  = GetComponent <SheepMovement>();
        sheepAnim   = GetComponent <Animator>();

        isDeathTimerRunning = true;
        isSheepTimeUp       = false;
        wolfTimer           = Random.Range(wolfTimerMin, wolfTimerMax);
        initTime            = Time.timeSinceLevelLoad;
        //Invoke("WolfTimerCounter", wolfTimer);

        if (wolfSpawnLocation == null)
        {
            wolfSpawnLocation = GameObject.Find("WolfSpawnLocation");
        }
    }
    public void processSheepMovementMessage(SheepMovementMessage _msg)
    {
        //server does not care about sheep movement receiving messages
        if (isServer)
        {
            return;
        }

        GameObject sheep = GameObject.Find(_msg.objectTransformName);

        if (sheep != null)
        {
            SheepMovement sheep_movement = sheep.GetComponent <SheepMovement>();

            if (sheep_movement.getState() != (int)State.Unavailable)
            {
                sheep_movement.localMove(_msg.objectPosition, _msg.objectRotation, _msg.time, _msg.objectAnimation);
            }
        }
    }
    private void shootSheep()
    {
        if (pickupSheep.getSheepStack().Count == 0)
        {
            impulseAccel        = InitialImpulseAccel;
            impulseStrenthSpeed = InitialImpulseSpeed;
            impulseStrenth      = InitialImpulseStrenght;

            updateImpulseUI();
            return;
        }

        orientPlayer();
        pickupSheep.updateSheepRotation();
        hideMira();

        GameObject sheep = pickupSheep.prepareToShoot();

        SheepMovement sheep_movement = sheep.GetComponentInChildren <SheepMovement>();
        Animator      sheep_animator = sheep.GetComponentInChildren <Animator>();
        Rigidbody     sheep_rb       = sheep.GetComponent <Rigidbody>();

        // set state to flying and anim state to shot
        sheep_movement.setFlying();
        IAnimState animState = new Shot(ref sheep_animator);

        sheep_movement.SetAnimState(animState);

        sheep_rb.velocity   = Vector3.zero;
        sheep_rb.useGravity = true;

        // sheepCollideWithBases(sheep);
        sheepCollideWithPlayers(sheep);
        sheep_movement.setPickedUpBy("");

        SendShootSheepMessage(sheep.transform.name, sheep_movement.getState(), sheep_animator.GetInteger("Index"), impulseStrenth);

        resetImpulseAndUI();
    }
    public void processShootSheepMessage(ShootSheepMessage _msg)
    {
        GameObject sheep = GameObject.Find(_msg.sheepName);

        if (sheep != null)
        {
            SheepMovement sheep_movement = sheep.GetComponent <SheepMovement>();
            Animator      sheep_animator = sheep.GetComponentInChildren <Animator>();
            Rigidbody     sheep_rb       = sheep.GetComponent <Rigidbody>();

            // set state to flying and anim state to shot
            sheep_movement.setFlying();
            IAnimState animState = new Shot(ref sheep_animator);
            sheep_movement.SetAnimState(animState);

            sheep_rb.velocity   = Vector3.zero;
            sheep_rb.useGravity = true;

            // ignoreCollisionWithBases(sheep, false);
            ignoreCollisionWithPlayers(sheep, false);
            sheep_movement.setPickedUpBy("");
        }
    }