override public void Update(Agent a, float dt) { FlyingSeed agentScript = a.GetComponent <FlyingSeed>(); if (agentScript.fallTimer > a.GetComponent <FlyingSeed>().fallTime) { agentScript.Spin(-1500.0f); agentScript.DropObject(); a.GetComponent <Rigidbody2D>().gravityScale = 0.5f; agentScript.DropObject(); if (a.GetComponent <Rigidbody2D>().velocity.y == 0) { a.SwitchState(0, new SeedGoUpState()); agentScript.rabitoGiratorio.transform.rotation = Quaternion.identity; agentScript.rabitoGiratorio.transform.Rotate(new Vector3(1, 0, 0), -90); agentScript.fallTimer = 0; } } else { agentScript.fallTimer += Time.deltaTime; } }
public override void Update(Agent a, float dt) { FlyingSeed agentScript = a.GetComponent <FlyingSeed>(); agentScript.Spin(500.0f); //Esta casteando explosión if (agentScript.timeCastingBlowUp < timeToExplode) { agentScript.timeCastingBlowUp += dt; } //Explota else { agentScript.BlowUp(); a.SwitchState(1, new SeedPathFollowState()); } }
public override void Update(Agent a, float dt) { FlyingSeed agentScript = a.GetComponent <FlyingSeed>(); agentScript.Spin(1500.0f); int currentTarget = agentScript.currentTarget; a.GetComponent <Rigidbody2D>().gravityScale = 0; if (Vector2.Distance(agentScript.VectorPatrolPoints[currentTarget], a.transform.position) > threshold) { //ATENUACIÓN SE SPEED CUANDO ESTA LLEGANDO if (Vector2.Distance(agentScript.VectorPatrolPoints[currentTarget], a.transform.position) > slowThreshold) { followSpeed = Mathf.Clamp(followSpeed + Time.deltaTime, minSpeed, maxSpeed); } //RECUPERA LA SPEED NORMAL SI NO ESTA LLEGANDO else { followSpeed = maxSpeed - (2 - Vector2.Distance(agentScript.VectorPatrolPoints[currentTarget], a.transform.position)); } //SET VELOCITY A CADA FRAME a.gameObject.GetComponent <Rigidbody2D>().velocity = ((agentScript.VectorPatrolPoints[currentTarget] - a.transform.position).normalized * followSpeed); } else { if (increasing) { if (currentTarget < agentScript.VectorPatrolPoints.Length - 1) { currentTarget++; agentScript.currentTarget++; } else { increasing = false; } } else { if (currentTarget > 0) { currentTarget--; agentScript.currentTarget--; } else { increasing = true; } } } if (a.touchedByPlayer) { a.SwitchState(1, new SeedBlowUpState()); } }