Beispiel #1
0
    public void _increaseBallSize()
    {
        SnowballController snowball = getSnowball();

        snowball.size += snowball.sizeIncreaseSpeed / 1500;
        snowball.updateSize();
    }
Beispiel #2
0
    public void _decreaseBallSize()
    {
        SnowballController snowball = getSnowball();

        snowball.size /= 2;
        snowball.updateSize();
    }
Beispiel #3
0
    void Awake()
    {
        snowballController = player.GetComponent <SnowballController>();

        // Reference to the camera transform.
        cam = transform;

        // Set camera default position.
        cam.position = player.position + Quaternion.identity * pivotOffset + Quaternion.identity * camOffset;
        cam.rotation = Quaternion.identity;

        // Get camera position relative to the player, used for collision test.
        relCameraPos    = transform.position - player.position;
        relCameraPosMag = relCameraPos.magnitude - 0.5f;

        // Set up references and default values.
        smoothPivotOffset      = pivotOffset;
        smoothCamOffset        = camOffset;
        defaultSmoothCamOffset = camOffset;
        defaultFOV             = cam.GetComponent <Camera>().fieldOfView;
        angleH = player.eulerAngles.y;

        ResetTargetOffsets();
        ResetFOV();
        ResetMaxVerticalAngle();
    }
    private void Start()
    {
        snowball_controller = GetComponent <SnowballController>();
        rigid_body          = GetComponent <Rigidbody2D>();

        Init();
    }
Beispiel #5
0
 public void Reset()
 {
     Snowball   = null;
     Lifetime   = null;
     LaunchVel  = Vector3.zero;
     TrailAlpha = 0f;
 }
Beispiel #6
0
	protected void OnCollisionEnter(Collision collision)
	{
		SnowballController component = collision.gameObject.GetComponent<SnowballController>();
		if (component != null)
		{
			OnHit(component.OwnerId);
		}
	}
Beispiel #7
0
    private void Start()
    {
        fire_countdown_max   = fire_countdown;
        moving_countdown_max = moving_countdown;

        snowball_controller = GetComponent <SnowballController>();
        rigid_body          = GetComponent <Rigidbody2D>();

        wave = GetComponentInParent <Wave>();
        wave.AddToWave(this);

        Init();
    }
Beispiel #8
0
 public void CollisionFromHitBox(Collision collision)
 {
     if (!DamagedBySnowballs)
     {
         return;
     }
     StartHitEffect();
     if (CanBeDamaged() && collision.collider.CompareTag("Snowball") && targetState != 0)
     {
         SetDamage();
         SnowballController component = collision.gameObject.GetComponent <SnowballController>();
         if (component != null && component.OwnerId != 0)
         {
             dispatcher.DispatchEvent(new IslandTargetsEvents.LocalPlayerHitTargetEvent(this));
         }
     }
 }
Beispiel #9
0
 //Бросаем любой неактивный снежок
 public void Attack()
 {
     Debug.Log(name + " Attack()");
     //find unusable ball in pull
     for (int i = 0; i < L_Snowball.Count; i++)
     {
         if (L_Snowball[i].gameObject.activeSelf == false)
         {
             SnowballController ball = L_Snowball[i];
             ball.gameObject.SetActive(true);
             ball.transform.position = ThrowBallPosition.position;
             ball.gameObject.layer   = 7;
             ball.Throw((Vector2.left + Vector2.up / 4) * Strange);
             break;
         }
     }
 }
Beispiel #10
0
 //Бросаем любой неактивный снежок вперёд
 void ThrowSnowball()
 {
     Debug.Log(name + " Throw ball()");
     GetComponent <SkeletonAnimation>().AnimationName = "Shoot";
     for (int i = 0; i < L_Snowball.Count; i++)
     {
         if (L_Snowball[i].gameObject.activeSelf == false)
         {
             SnowballController ball = L_Snowball[i];
             ball.gameObject.SetActive(true);
             ball.gameObject.layer   = 6;
             ball.transform.position = transform.position + ThrowBallPositionOffset;
             ball.Throw(ThrowDirect);
             break;
         }
     }
     lineRenderer.positionCount = 0;
 }
Beispiel #11
0
    public void spawnSnowball()
    {
        latestSnowball = (GameObject)Instantiate(this.snowball);
        latestSnowball.transform.position = new Vector3(0, 60, 0);

        SnowballController snowballController = latestSnowball.GetComponent <SnowballController>();

        if (snowballSpawnSize > 0)
        {
            snowballController.startSize = snowballSpawnSize;
            snowballController.toSnowball();
        }

        foreach (SnowCamera followSnowball in GameObject.FindObjectsOfType <SnowCamera>())
        {
            followSnowball.player = latestSnowball.transform;
        }

        foreach (DrawTracks snowSurface in GameObject.FindObjectsOfType <DrawTracks>())
        {
            snowSurface._snowball = latestSnowball.transform;
        }
    }
Beispiel #12
0
    void Update()
    {
        Vector3 forward;

        SnowballController snowball = getSnowball();

        if (snowball.size > 0)
        {
            forward = mainCamera.transform.TransformDirection(Vector3.forward); //snowball
        }
        else
        {
            forward = mainCamera.transform.TransformDirection(Vector3.up); //snowflake
        }
        forward.y = 0;
        forward   = forward.normalized;

        Vector3 right = new Vector3(forward.z, 0, -forward.x).normalized;

        float v = getVerticalInput();
        float h = getHorizontalInput();

        Vector3 targetDirection = h * right + v * forward;


        bool grounded = IsGrounded();

        if (grounded)
        {
            targetDirection = targetDirection.normalized * moveSpeed;
        }
        else
        {
            targetDirection = targetDirection.normalized * moveSpeedAir;
        }

        targetDirection *= Time.deltaTime;

        snowball.GetComponent <Rigidbody>().AddForce(targetDirection);

        if (grounded)
        {
            if (manualInputJump || Input.GetButton("Jump"))
            {
                if (lastJumpTime + jumpRepeatTime < Time.time)
                {
                    lastJumpTime = Time.time;
                    snowball.GetComponent <Rigidbody>().AddForce(new Vector3(0, jumpSpeed, 0));
                }
            }
        }


        if (Input.GetKey(KeyCode.C) || manualInputConnect)
        {
            snowball.requestConnectChange();
        }

        if (Input.GetKey(KeyCode.R) || manualInputRespawn)
        {
            inventory.inventoryUI.RemoveSelectedItems();
            spawn.trySpawnSnowball();
        }
    }
Beispiel #13
0
    private bool IsGrounded()
    {
        SnowballController snowball = getSnowball();

        return(Physics.Raycast(snowball.transform.position, new Vector3(0, -1, 0), snowball.jumpAllowDistance + snowball.size));
    }
 public void UnspawnSnowball(SnowballController snowball)
 {
     snowballPool.Unspawn(snowball.gameObject);
 }
Beispiel #15
0
    /*public void putOnMe(Transform item)
     * {
     *  puttingOn = spawn.latestSnowball.GetComponent<SnowballController>();
     *  puttingObject = item;
     * }*/

    public void putOnMe(GameObject item)
    {
        item.layer            = 0;
        item.transform.parent = spawn.latestSnowball.transform;
        puttingOn             = spawn.latestSnowball.GetComponent <SnowballController>();

        if (item.name == "Pot" || item.name == "Bottom button" || item.name == "Middle button")
        {
            //item.transform.localPosition = new Vector3(0.05f, 0.0f, 0.28f);

            item.transform.localPosition = new Vector3(0, 1, 0.2f) * puttingOn.size / 2;
            puttingObject = item.transform;
        }



        //eyes 08,05,02

        /*else if (item.name == "button.000 (1)")
         * {
         *  //item.transform.localPosition = new Vector3(0.05f, 0.0f, 0.28f);
         *
         *  item.transform.localPosition = new Vector3(0.8f, 0.5f, 0.02f) * puttingOn.size / 2;
         *  puttingObject = item.transform;
         *
         * }
         * else if (item.name == "button.000 (4)")
         * {
         *  item.transform.localPosition = new Vector3(0.8f, 0.5f, -0.3f) * puttingOn.size / 2;
         *  puttingObject = item.transform;
         * }*/

        else if (item.name == "Hat")
        {
            item.transform.localPosition = new Vector3(0.05f, 0.0f, 0.28f);

            item.transform.localPosition    = new Vector3(0, 1, 0) * puttingOn.size / 2;
            item.transform.localEulerAngles = new Vector3(
                0, 0, 0
                );
            puttingObject = item.transform;
        }

        else if (item.name == "Carrot")
        {
            item.transform.localPosition = new Vector3(1, 0, 0) * puttingOn.size / 2.4f;
            item.transform.eulerAngles   = new Vector3(
                -20, 0, 0
                );
            Vector3 snowballPos = puttingOn.transform.position;

            puttingObject = item.transform;
        }

        /*else if (item.name == "pipe")
         * {
         *
         *  item.transform.localPosition = Vector3.zero;
         *  //item.transform.localPosition = new Vector3(0.1f, -0.2f, 0) * puttingOn.size*5;
         *  Vector3 snowballPos = puttingOn.transform.position;
         *
         *  item.transform.localRotation = Quaternion.Euler(new Vector3(10, 0, 0));
         *
         *  puttingObject = item.transform;
         * }*/


        item.SetActive(true);
    }
Beispiel #16
0
 void Start()
 {
     spawn = GameObject.Find("Spawn").GetComponent <Spawn>();
     snowballController = this.GetComponent <SnowballController>();
 }