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; } }
override public void Update(Agent a, float dt) { FlyingSeed agentScript = a.GetComponent <FlyingSeed>(); bool rising = agentScript.rising; Agent agent = a.gameObject.GetComponent <Agent>(); Vector3 targetPos; if (rising) { targetPos = agentScript.orbitPos + new Vector3(0, idleOffset, 0); } else { targetPos = agentScript.orbitPos - new Vector3(0, idleOffset, 0); } if (Vector2.Distance(targetPos, agent.transform.position) > idleThreshold) { agent.GetComponent <Rigidbody2D>().velocity = (targetPos - agent.transform.position).normalized * idleVelocity; } else { rising = !rising; } if (agent.stompedOn) { agent.SwitchState(0, new SeedFallState()); } }
override public void OnEnter(Agent a) { FlyingSeed agentScript = a.GetComponent <FlyingSeed>(); agentScript.timeOnTheGround = 0; a.GetComponent <Rigidbody2D>().gravityScale = 0; agentScript.stompedOn = false; agentScript.detectStompObject.GetComponent <DetectStomp>().active = true; }
override public void OnEnter(Agent a) { FlyingSeed agentScript = a.GetComponent <FlyingSeed>(); agentScript.orbitPos = a.gameObject.transform.position; a.gameObject.GetComponent <Rigidbody2D>().gravityScale = 0; //Debug.Log("Changing orbit pos"); a.GetComponent <Agent>().stompedOn = false; agentScript.detectStompObject.GetComponent <DetectStomp>().active = true; }
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()); } }
override public void Update(Agent a, float dt) { FlyingSeed agentScript = a.GetComponent <FlyingSeed>(); if (agentScript.grabbedObject == null) { agentScript.CheckForObjects(); } if (stompTime > stompTimer) { stompTimer += dt; } //Lleva el tiempo establecido en el suelo, así que sube hasta alcanzar speed>1 if (agentScript.timeOnTheGround > maxTimeOnTheGround) { if (a.GetComponent <Rigidbody2D>().velocity.y < 1) { a.GetComponent <Rigidbody2D>().velocity = new Vector2(0, a.GetComponent <Rigidbody2D>().velocity.y + speedUp * Time.deltaTime); } else { a.SwitchState(0, new SeedIdleState()); } //Falta tiempo en el suelo } else { agentScript.timeOnTheGround += Time.deltaTime; } //Comprobación de cambio de estado if (agentScript.stompedOn && stompTimer > stompTime && agentScript.timeOnTheGround > maxTimeOnTheGround) { agentScript.SwitchState(0, new SeedFallState()); stompTimer = 0; } }
void Start() { rb = GetComponent <Rigidbody2D>(); brotherScript = brotherObject.GetComponent <FlyingSeed>(); fallTime = 1.0f; if (Path_Points.Length != 0) { if (Path_Points[0] != null) { VectorPatrolPoints = new Vector3[Path_Points.Length]; for (int i = 0; i < VectorPatrolPoints.Length; i++) { VectorPatrolPoints[i] = new Vector3(Path_Points[i].position.x, Path_Points[i].position.y, Path_Points[i].position.z); Destroy(Path_Points[i].gameObject); } } } stompedOn = false; currentTarget = 0; InitTransformable(); isPunchable = false; isBreakable = false; interactuableBySmash = false; offset = GameLogic.instance.worldOffset; if (worldAssignation == world.DAWN) { rb.bodyType = RigidbodyType2D.Kinematic; } else { } }
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()); } }