void Start() { CurrFrameType = FrameType.Regular; movement = GetComponent <BaseMovement> (); hitBoxes = GetComponent <HitBoxes> (); currentHealth = totalHealth; try{ stageManager = FindObjectOfType <StageManager>(); if (teamNumber == 1) { lockOnTargets.AddRange(stageManager.team2); lockOnTarget = lockOnTargets [0]; } else if (teamNumber == 2) { lockOnTargets.AddRange(stageManager.team1); lockOnTarget = lockOnTargets [0]; } }catch { //lockOnTargets.Add (FindObjectsOfType<FighterClass>); foreach (FighterClass fighter in FindObjectsOfType <FighterClass>()) { if (fighter.teamNumber != teamNumber) { lockOnTargets.Add(fighter.gameObject); } } lockOnTarget = lockOnTargets [0]; } if (teamNumber == 2) { ToggleDirection(); } }
public void SetHitbox(HitBoxes value) { for (var i = 0; i < 6; i++) { if (i == (int)value) { hitboxes[i].enabled = true; } else { hitboxes[i].enabled = false; } } }
//targethitboxesの中身が現在のsimpleAnimationの構成と一致するかを返す public bool IsStructureSame(HitBoxes targethitboxes) { if (hitboxes == null) { return(true); } var states = simpleAnimation.GetEditorStates(); foreach (var e in targethitboxes.data) { //simpleanimationに存在しないstate名がtargethitboxesの中にあれば構成が一致していないとみなす if (!states.Any(s => s.name == e.Key)) { return(false); } } return(true); }
// FIX: stop when near objective private void MoveTo(Vector2 objectiveV, float speed) { var movingDirection = new Vector2(); var agentV = new Vector2(X, Y); //var distance = Math.Abs(agentV.X - objectiveV.X) + Math.Abs(agentV.Y + objectiveV.Y); // just touching the objective is enough if ((Math.Abs(agentV.X - objectiveV.X) > Width || Math.Abs(agentV.Y + objectiveV.Y) > Height) && !HitBoxes.FirstOrDefault().Value.CollideWith(Player.Instance.HitBoxes.FirstOrDefault().Value)) // first or value dependant key? { //movingDirection = objectiveV - agentV; //movingDirection.Normalize(); ////Debug.WriteLine("{0} {1} {2} {3} {4}", playerV, agentV, movingDirection, bestDelta, level.speed); //Vx += movingDirection.X * deltaTime * speed; //Vy += movingDirection.Y * deltaTime * speed; if (useAI) { var path = AI.CalculatePath(this, objectiveV); if (path == null) // temp workaround test { return; } movingDirection = path[0]; } else { movingDirection = objectiveV - agentV; } movingDirection.Normalize(); X += movingDirection.X * DeltaTime * speed; Y += movingDirection.Y * DeltaTime * speed; CalculateMovingState(movingDirection); MovingDirection = movingDirection; } }