protected virtual void CheckAndAddEntity(ReflectedEntity newRefEnt)
        {
            if (FilterByForceType && newRefEnt.ForceType != Type)
            {
                return;
            }
            if (FilterByEntityTypePattern && !newRefEnt.EntityType.MatchPattern(NetStructs.EntityType.FromString(EntityType)))
            {
                return;
            }
            if (FilterByMarkingText && (null == markingTextsList || markingTextsList.Count != MarkingTexts.Length))
            {
                markingTextsList = new List <string>();
                foreach (string markingText in MarkingTexts)
                {
                    markingTextsList.Add(markingText.ToLower());
                }
            }
            if (FilterByMarkingText && !markingTextsList.Contains(newRefEnt.MarkingText.ToLower()))
            {
                return;
            }

            GameObject newImage = Instantiate(ImagePrefab, MinimapTransform);

            EntityImageDictionary.Add(newRefEnt, new ImagePosition(newImage, newImage.GetComponent <MinimapPointPositioner>()));
            newImage.transform.localScale *= ImageScale;
            Text text = newImage.GetComponentInChildren <Text>();

            if (text)
            {
                newImage.GetComponentInChildren <Text>().text = newRefEnt.MarkingText;
            }
            newImage.GetComponent <Image>().enabled = !StartHidden;
        }
 private void CheckAndRemoveEntity(ReflectedEntity leavingRefEnt)
 {
     if (EntityImageDictionary.ContainsKey(leavingRefEnt))
     {
         Destroy(EntityImageDictionary[leavingRefEnt].gameObject);
         EntityImageDictionary.Remove(leavingRefEnt);
     }
 }
 private void LookForOperatorEntityId()
 {
     OperatorReflectedEntity = ReflectedEntities.LookUpByMarkingText(OperatorMarkingText, false);
     if (null != OperatorReflectedEntity)
     {
         operatorEntityId = OperatorReflectedEntity.EntityId;
     }
 }
Пример #4
0
    private void Start()
    {
        exerciseConnection = FindObjectOfType <ExerciseConnection>();
        reflectedEntity    = GetComponent <ReflectedEntity>();

        if (exerciseConnection == null || reflectedEntity == null)
        {
            Destroy(this);
        }

        entityId = reflectedEntity.EntityId;
        exerciseConnection.SubscribeFireInteraction(FireInteractionHandler);
    }
    public void CreateNewDetonation(DetonationInteraction detInteraction)
    {
        string munitionType = detInteraction.munitionType.ToString();

        GameObject reflectedPrefab = null;

        foreach (var reflectedModelPair in ReflectedModels)
        {
            if (reflectedModelPair.MunitionType == munitionType)
            {
                reflectedPrefab = reflectedModelPair.ReflectedPrefab;
                break;
            }
        }

        if (reflectedPrefab == null)
        {
            return;
        }

        GameObject currentDetonation = Instantiate(reflectedPrefab);

        RotateBulletHole bulletHole = currentDetonation.GetComponentInChildren <RotateBulletHole>();

        if (null != bulletHole)
        {
            ReflectedEntity attacker = ReflectedEntities.GetEntity(detInteraction.attacker);
            if (null != attacker)
            {
                bulletHole.AttackerPosition = attacker.transform.position;
            }
            else
            {
                foreach (PublishedEntity ent in  ExerciseConnection.LocalPublishedEntities)
                {
                    if (detInteraction.attacker == ent.MyEntityId)
                    {
                        bulletHole.AttackerPosition = ent.transform.position;
                    }
                }
            }
        }
        DetonationParticles detParticles = currentDetonation.GetComponent <DetonationParticles>();

        if (null != detParticles)
        {
            detParticles.PlayImpact(detInteraction.result);
        }
        Rigidbody detonationRb = currentDetonation.GetComponent <Rigidbody>();

        if (detonationRb != null)
        {
            detonationRb.velocity = detInteraction.linVelocity.ToVector3();
            //check if detonation has collider to elevate the detonation above the ground
            Collider detonationCollider = currentDetonation.GetComponent <Collider>();
            //collider.bounds.size.y gives the height of the collider.
            //if detonation has a rigidbody but no collider, default to 15cm above ground
            float y = null != detonationCollider ? detonationCollider.bounds.size.y + 0.02f : 0.15f;
            currentDetonation.transform.position = detInteraction.worldLocation.ToVector3() + new Vector3(0, y, 0);
        }
        else
        {
            currentDetonation.transform.position = detInteraction.worldLocation.ToVector3();
        }
    }