コード例 #1
0
 TrigEvent(GameObject other)
 {
     // if collid with body, according to https://www.youtube.com/watch?v=35lpSHgvibU
     if (other.CompareTag("Body"))
     {
         ArenaNode  OtherNode           = Utils.GetBottomLevelArenaNodeInGameObject(other);
         ArenaNode  ThisNode            = Utils.GetBottomLevelArenaNodeInGameObject(gameObject);
         List <int> ThisNodeCoordinate  = ThisNode.GetCoordinate();
         List <int> OtherNodeCoordinate = OtherNode.GetCoordinate();
         if (!Utils.IsListEqual(ThisNodeCoordinate, OtherNodeCoordinate,
                                Mathf.Min(ThisNodeCoordinate.Count, OtherNodeCoordinate.Count)))
         {
             ThisNode.Kill();
         }
     }
 } // TrigEvent
コード例 #2
0
        TrigEvent(GameObject other)
        {
            if (TrigTags.Contains(other.tag))
            {
                ArenaNode OtherNode = Utils.GetBottomLevelArenaNodeInGameObject(other);
                ArenaNode ThisNode  = Utils.GetBottomLevelArenaNodeInGameObject(gameObject);

                ArenaNode SubjectNode;
                if (SubjectType == SubjectTypes.This)
                {
                    SubjectNode = ThisNode;
                }
                else
                {
                    SubjectNode = OtherNode;
                }

                if (SubjectNode == null)
                {
                    return;
                }

                if (IsMatchNodeCoordinate)
                {
                    if ((ThisNode == null) || (OtherNode == null))
                    {
                        return;
                    }
                    else
                    {
                        List <int> ThisNodeCoordinate  = ThisNode.GetCoordinate();
                        List <int> OtherNodeCoordinate = OtherNode.GetCoordinate();
                        if (!Utils.IsListEqual(ThisNodeCoordinate, OtherNodeCoordinate,
                                               Mathf.Min(ThisNodeCoordinate.Count, OtherNodeCoordinate.Count)))
                        {
                            return;
                        }
                    }
                }


                if (IsKill)
                {
                    SubjectNode.Kill();
                }

                foreach (string Attribute_ in IncrementAttributes.Keys)
                {
                    if (float.Parse(IncrementAttributes[Attribute_]) != 0f)
                    {
                        float Scale_ = 1f;
                        if (CompareTag("Eatable"))
                        {
                            Scale_ = transform.localScale.y;
                        }
                        SubjectNode.IncrementAttribute(Attribute_,
                                                       float.Parse(IncrementAttributes[Attribute_]) * Scale_);
                    }
                }

                if (IsCarried)
                {
                    ToFollow         = other;
                    RelativePosition = transform.position - ToFollow.transform.position;
                }
            }
        } // TrigEvent