protected virtual void Start() { currentLife = maxLife; isAlive = true; baseAnim.SetBool("IsAlive", isAlive); actorCollider = GetComponent <ActorCollider>(); actorCollider.SetColliderStance(true); }
public LevelState(Map map, InputHandler inputHandler) { this.map = map; level = "L1"; this.inputHandler = inputHandler; collider = new Collider(); lives = new Lives(); actCollider = new ActorCollider(); youkais = new List <Actor>(); }
private void OnAllTriggerEnter(ActorCollider other) { if (this.bulletCallback != null && other && other.Actor) { this.bulletCallback.Invoke(this, new XPoint { position = other.Actor.FixTransform.get_position(), rotation = other.Actor.FixTransform.get_rotation() }, other.Actor); } }
private void DealOcclusion(EntityParent pet) { Transform fixTransform = pet.Actor.FixTransform; Vector3 normalized = (new Vector3(base.get_transform().get_position().x, 0f, base.get_transform().get_position().z) - new Vector3(fixTransform.get_position().x, 0f, fixTransform.get_position().z)).get_normalized(); Vector3 vector = fixTransform.get_position() + normalized * 0.01f + new Vector3(0f, 0.5f, 0f); Vector3 normalized2 = (base.get_transform().get_position() - vector).get_normalized(); float num = Vector3.Distance(vector, base.get_transform().get_position()); RaycastHit[] array = Physics.RaycastAll(vector, normalized2, num); for (int i = 0; i < array.Length; i++) { ActorCollider component = array[i].get_collider().get_transform().GetComponent <ActorCollider>(); Debug.LogError("ac=" + component); if (component != null && component.Actor != null && component.Actor.GetEntity() != null) { Debug.LogError("ac.Actor=" + component.Actor); Debug.LogError("ac.Actor.GetEntity()=" + component.Actor.GetEntity()); long iD = component.Actor.GetEntity().ID; this.monsterIds.Add(iD); ShaderEffectUtils.SetIsNearCamera(array[i].get_collider().get_transform(), true); } } }
private void OnTriggerEnter(Collider other) { if (other.get_gameObject().get_layer() != LayerSystem.NameToLayer("Default") && other.get_gameObject().get_layer() != LayerSystem.NameToLayer("Terrian")) { ActorCollider component = other.GetComponent <ActorCollider>(); if (!component) { return; } if (!component.Actor) { return; } if (component.Actor.GetEntity() == null) { return; } if (!component.Actor.GetEntity().IsEntitySelfType) { return; } this.OnSelfEnter(); } }
public override void Initialize(ActorBaseComponent actorComponent) { base.Initialize(actorComponent); m_ActorCollider = m_ActorNode as ActorCollider; if (m_ActorCollider is ActorColliderCircle) { gameObject.AddComponent(typeof(CircleCollider2D)); CircleCollider2D circleCollider = gameObject.GetComponent <CircleCollider2D>(); ActorColliderCircle actorCircleCollider = m_ActorCollider as ActorColliderCircle; circleCollider.radius = actorCircleCollider.Radius; m_Collider = circleCollider; } else if (m_ActorCollider is ActorColliderRectangle) { gameObject.AddComponent(typeof(BoxCollider2D)); BoxCollider2D boxCollider = gameObject.GetComponent <BoxCollider2D>(); ActorColliderRectangle actorRectangleCollider = m_ActorCollider as ActorColliderRectangle; boxCollider.size = new Vector2(actorRectangleCollider.Width, actorRectangleCollider.Height); m_Collider = boxCollider; } else if (m_ActorCollider is ActorColliderPolygon) { gameObject.AddComponent(typeof(PolygonCollider2D)); PolygonCollider2D polygonCollider = gameObject.GetComponent <PolygonCollider2D>(); ActorColliderPolygon actorPolygonCollider = m_ActorCollider as ActorColliderPolygon; polygonCollider.pathCount = 1; float[] contourBuffer = actorPolygonCollider.ContourVertices; Vector2[] points = new Vector2[contourBuffer.Length / 2]; int readIdx = 0; for (int i = 0; i < points.Length; i++) { points[i] = new Vector2(contourBuffer[readIdx], contourBuffer[readIdx + 1]); readIdx += 2; } polygonCollider.SetPath(0, points); m_Collider = polygonCollider; } else if (m_ActorCollider is ActorColliderTriangle) { gameObject.AddComponent(typeof(PolygonCollider2D)); PolygonCollider2D polygonCollider = gameObject.GetComponent <PolygonCollider2D>(); ActorColliderTriangle actorTriangleCollider = m_ActorCollider as ActorColliderTriangle; polygonCollider.pathCount = 1; float hwidth = actorTriangleCollider.Width / 2.0f; float hheight = actorTriangleCollider.Height / 2.0f; Vector2[] points = new Vector2[3]; points[0] = new Vector2(-hwidth, -hheight); points[1] = new Vector2(0.0f, hheight); points[2] = new Vector2(hwidth, -hheight); polygonCollider.SetPath(0, points); m_Collider = polygonCollider; } }
public void InitializeFromAsset(ActorAsset actorAsset) { HideFlags hideFlags = HideFlags.DontSaveInEditor | HideFlags.DontSaveInBuild | HideFlags.DontUnloadUnusedAsset | HideFlags.HideInHierarchy | HideFlags.HideInInspector; m_ActorAsset = actorAsset; if (!actorAsset.Loaded && !actorAsset.Load()) { #if UNITY_EDITOR Debug.Log("Bad actorAsset referenced by Actor2D."); #endif return; } RemoveNodes(); m_ActorInstance = new Actor(); m_ActorInstance.Copy(m_ActorAsset.Actor); OnActorInstanced(); // Instance actor bones first as our image nodes need to know about them if they are skinned. { //ActorNode[] allNodes = m_ActorInstance.AllNodes; IList <Nima.ActorComponent> actorComponents = m_ActorInstance.Components; m_Nodes = new ActorNodeComponent[actorComponents.Count]; int imgNodeIdx = 0; for (int i = 0; i < actorComponents.Count; i++) { Nima.ActorComponent ac = actorComponents[i]; ActorNode an = ac as ActorNode; if (an == null) { continue; } GameObject go = null; ActorImage ai = an as ActorImage; if (ai != null) { ActorNodeComponent nodeComponent = MakeImageNodeComponent(imgNodeIdx, ai); nodeComponent.Node = ai; go = nodeComponent.gameObject; m_Nodes[i] = nodeComponent; imgNodeIdx++; } else { ActorCollider actorCollider = an as ActorCollider; if (actorCollider != null && InstanceColliders) { go = new GameObject(an.Name, typeof(ActorColliderComponent)); ActorColliderComponent colliderComponent = go.GetComponent <ActorColliderComponent>(); colliderComponent.Node = actorCollider; m_Nodes[i] = colliderComponent; } // else // { // go = new GameObject(an.Name, typeof(ActorNodeComponent)); // ActorNodeComponent nodeComponent = go.GetComponent<ActorNodeComponent>(); // nodeComponent.Node = an; // m_Nodes[i] = nodeComponent; // } } if (go != null) { go.hideFlags = hideFlags; } } // After they are all created, initialize them. for (int i = 0; i < m_Nodes.Length; i++) { ActorNodeComponent nodeComponent = m_Nodes[i]; if (nodeComponent != null) { nodeComponent.Initialize(this); } } } OnActorInitialized(); #if UNITY_EDITOR LateUpdate(); UpdateEditorBounds(); #endif }
void Start() { //start init collider = GetComponent <ActorCollider>(); newPosition = new Matrix2(transform.position.x, transform.position.y); }
public override void Apply(ActorComponent component, float mix) { ActorCollider collider = component as ActorCollider; collider.IsCollisionEnabled = m_Value; }
private void OnAllTriggerExit(ActorCollider other) { }