public override void ArtificialIntelleginceControl() { base.ArtificialIntelleginceControl(); if (target == null) { if (transform.position != spawnpoint) { if (returnTimer <= 0) { if (!dispapering) { StartCoroutine(FadeOutRespawn()); dispapering = true; } } else { returnTimer -= Time.deltaTime; } } else { dispapering = false; } SetAnimation("idle", true); target = GetClosestTarget(250); } else { if (CheckTargetDistance(target, 400) && !Physics2D.Linecast(transform.position, target.transform.position, lay)) { SetAnimation("attack", true); direction = LookAtTarget(target); s_node nextNode = nodegraph.PosToNode((Vector2)transform.position + (direction * 10)); CHARACTER_STATE = CHARACTER_STATES.STATE_MOVING; } else { target = null; } } }
void COLLISIONDET() { CurrentNode = CheckNode(transform.position + offsetCOL); if (IS_KINEMATIC) { if (collision != null) { collision.isTrigger = false; } if (only_land) { in_wall = true; } // s_gui.AddText(nodeg.PosToVec(new Vector2( positioninworld.x + collision.size.x / 2, positioninworld.y + collision.size.y / 2)).ToString()); if (CurrentNode != null) { //print(le1.COLTYPE); switch (CHARACTER_STATE) { case CHARACTER_STATES.STATE_IDLE: case CHARACTER_STATES.STATE_MOVING: if ((COLLISION_T)CurrentNode.COLTYPE != COLLISION_T.DITCH && (COLLISION_T)CurrentNode.COLTYPE != COLLISION_T.WATER_TILE && (COLLISION_T)CurrentNode.COLTYPE != COLLISION_T.NO_LASTPOSITION && (COLLISION_T)CurrentNode.COLTYPE != COLLISION_T.LANDING_DOWN && (COLLISION_T)CurrentNode.COLTYPE != COLLISION_T.FALLING) { if (grounded && !only_land) { lastposbeforefall = transform.position; } } if (only_land) { switch ((COLLISION_T)CurrentNode.COLTYPE) { case COLLISION_T.DITCH: case COLLISION_T.LANDING_DOWN: case COLLISION_T.LANDING_RIGHT: case COLLISION_T.LANDING_UP: case COLLISION_T.LANDING_LEFT: lastposbeforefall = transform.position; break; } } break; } if ((COLLISION_T)CurrentNode.COLTYPE != COLLISION_T.FALLING_ON_LAND && (COLLISION_T)CurrentNode.COLTYPE != COLLISION_T.WATER_TILE) { terminalspd = terminalSpeedOrigin; } if ((COLLISION_T)CurrentNode.COLTYPE != COLLISION_T.WATER_TILE) { freezetimer = 1.45f; } if ((COLLISION_T)CurrentNode.COLTYPE != COLLISION_T.NONE && (COLLISION_T)CurrentNode.COLTYPE != COLLISION_T.NO_DEPOSEESS) { if (shadow != null) { shadow.GetComponent <SpriteRenderer>().color = Color.clear; } in_wall = true; } else { if (shadow != null) { shadow.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 0.45f); } in_wall = false; } switch ((COLLISION_T)CurrentNode.COLTYPE) { case COLLISION_T.NONE: if (only_land) { transform.position = lastposbeforefall; } else { canjump = true; in_wall = false; } break; case COLLISION_T.FALLING: in_wall = true; if (CHARACTER_STATE != CHARACTER_STATES.STATE_FALLING) { print("check"); rbody2d.velocity = Vector2.zero; if (grounded) { fallposy = nodegraph.CheckYFall(CurrentNode, (int)COLLISION_T.FALLING); print(fallposy); transform.position = CurrentNode.realPosition; CHARACTER_STATE = CHARACTER_STATES.STATE_FALLING; } } break; case COLLISION_T.FALLING_ON_LAND: in_wall = true; if (scaleLedges) { if (grounded) { terminalspd = terminalSpeedOrigin / 2.5f; break; } else { terminalspd = terminalSpeedOrigin / 1.5f; break; } } if (CurrentNode != null) { if (grounded && CHARACTER_STATE != CHARACTER_STATES.STATE_FALLING) { if (rbody2d != null) { rbody2d.velocity = Vector2.zero; } fallposy = nodegraph.CheckYFall(CurrentNode, (int)COLLISION_T.FALLING_ON_LAND) // + collision.offset.y + 80 ; print(fallposy); transform.position = new Vector3(transform.position.x, CurrentNode.realPosition.y); CHARACTER_STATE = CHARACTER_STATES.STATE_FALLING; } } break; case COLLISION_T.LANDING_DOWN: case COLLISION_T.LANDING_UP: case COLLISION_T.LANDING_LEFT: case COLLISION_T.LANDING_RIGHT: if (only_land) { in_wall = false; } if (grounded && !only_land && CHARACTER_STATE != CHARACTER_STATES.STATE_DASHING) { transform.position = lastposbeforefall; /* * if (GetType() == typeof(o_plcharacter)) * transform.position = lastposbeforefall; * else * ResetLocation(); */ } break; case COLLISION_T.DITCH: in_wall = true; if (grounded && !only_land && CHARACTER_STATE != CHARACTER_STATES.STATE_DASHING) { transform.position = lastposbeforefall; } break; case COLLISION_T.WATER_TILE: in_wall = true; if (!icetolerant) { if (grounded) { terminalspd = terminalSpeedOrigin / 4; canjump = false; if (freezetimer > 0) { freezetimer -= Time.deltaTime; } else { transform.position = lastposbeforefall; } } } else { terminalspd = terminalSpeedOrigin / 3; } break; } } } else { collision.isTrigger = true; } }