public void ThrowGrenade()
    {
        ThrowData data = new ThrowData(this, Target, ActiveSkill, myGrenades[0]);

        myGrenades[0].Throw(data);
        OnThrowStart.Invoke(data);
        FinishedThrowingGrenade();
    }
示例#2
0
 void DisableSkills(ThrowData data)
 {
     data.Source.OnThrowStart.RemoveListener(DisableSkills);
     for (int i = 0; i < ContentPanel.transform.childCount; i++)
     {
         Transform obj = ContentPanel.transform.GetChild(i);
         obj.gameObject.SetActive(false);
     }
 }
示例#3
0
    private void InitializePrefabs()
    {
        Ball playerBallComponent = playerBall.GetComponent <Ball>();

        if (playerBallComponent != null)
        {
            ThrowData data = new ThrowData(currentGameMode.initialVelocity, currentGameMode.VelocityModifier, Physics2D.gravity, currentGameMode.launchOffsetPerLevel, currentGameMode.yBallSpawnCoordinates);
            playerBallComponent.Init(OnPlayerScored, OnPlayerFailed, scoreEvent, data);
        }
    }
示例#4
0
 public void Init(UnityEvent onScoreCallback, ThrowData initialData)
 {
     if (rigidBody == null)
     {
         rigidBody = GetComponent <Rigidbody2D>();
     }
     onScoreCallback.AddListener(OnPlayerScored);
     throwData = initialData;
     SetupScreenRelativeYThrowRange();
 }
 public void Update(float deltaTime)
 {
     if (currentThrow != null)
     {
         throwTime += deltaTime;
         Vector3 arc    = new Vector3(0, Mathf.Sin(throwTime * Mathf.PI), 0);
         Vector3 newPos = Vector3.Lerp(currentThrow.Source.Position, currentThrow.Target.Position, throwTime * speed);
         SetPosition(newPos + arc);
         if (Vector3.Distance(newPos, currentThrow.Target.Position) == 0)
         {
             currentThrow.Target.ReceiveGrenade(this); // TODO: This is probably bad... but whatever
             OnCaught.Invoke(currentThrow);
             currentThrow.Source.ActionCompleted();
             currentThrow = null;
             throwTime    = 0;
         }
     }
 }
示例#6
0
    void DrawRay()
    {
        if (drawRay)
        {
            ThrowData throwData         = CalculateThrowData();
            Vector3   previousDrawPoint = holdObject.transform.position;

            int resolution = 30;
            for (int i = 1; i <= resolution; i++)
            {
                float   simulationTime = i / (float)resolution * throwData.timeToTarget;
                Vector3 displacement   = throwData.initialVelocity * simulationTime + Vector3.up * gravity * simulationTime * simulationTime / 4;
                Vector3 drawPoint      = holdObject.transform.position + displacement;
                Debug.DrawLine(previousDrawPoint, drawPoint);
                previousDrawPoint = drawPoint;
            }
        }
    }
 void GrenadeThrow(ThrowData data)
 {
     //sources[data.Grenade].clip = Clips.FirstOrDefault(c => c.name.Contains("ThrowWhistle"));
     sources[data.Grenade].clip = Clips[Random.Range(0, Clips.Length)];
     sources[data.Grenade].Play();
 }
 public void Catch(ThrowData data)
 {
     OnCaught.Invoke(data);
     currentThrow = null;
 }
 public void Throw(ThrowData data)
 {
     currentThrow = data;
     OnThrown.Invoke(data);
 }
示例#10
0
文件: Ball.cs 项目: TalimeQ/TapGolf
 public void Init(UnityAction scoreCallback, UnityAction loseCallback, UnityEvent scoreListener, ThrowData initialData)
 {
     throwComponent.Init(scoreListener, initialData);
     collisionComponent.Init(scoreCallback, loseCallback, throwComponent);
 }
示例#11
0
    public void ThrowGrenade(ThrowData data)
    {
        GameObject obj = GrenadeToGameObj[data.Grenade];

        obj.GetComponent <Animator>().SetTrigger("isMoving");
    }
示例#12
0
 public void CatchGrenade(ThrowData data)
 {
     grenadeSettle(data.Grenade);
 }
示例#13
0
 protected void CharacterStartThrow(ThrowData data)
 {
 }