Пример #1
0
    public void InitFromLineInfo(HitScanInfo hsi, GameObject parent, FactionHolder fh = null)
    {
        float deg = Mathf.Deg2Rad * parent.transform.rotation.eulerAngles.y;

        aimPoint = Orientation.OrientToVectorZ(hsi.AimDirection, deg);
        if (hsi.FollowCharacter)
        {
            transform.SetParent(parent.transform);
            transform.localPosition = hsi.CreatePos;
            transform.localRotation = Quaternion.identity;
        }
        else
        {
            transform.position += Orientation.OrientToVectorZ(hsi.CreatePos, deg);
        }
        setRange(hsi.MaxRange);
        Damage = hsi.Damage;
        setAimPoint(aimPoint);
        Duration            = hsi.HitboxDuration;
        Knockback           = Orientation.OrientToVectorZ(hsi.Knockback, deg);
        IsFixedKnockback    = true;
        CanPenetrateWall    = hsi.CanPenetrateWall;
        Creator             = parent;
        EnemiesCanPenetrate = hsi.PenetrativePower;
        if (fh != null)
        {
            fh.SetFaction(gameObject);
        }
        hitCallback = hsi.hitCallback;
        AddElement(hsi.Element);
        Stun = hsi.Stun;
        Init();
    }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     foreach (KeyValuePair <string, Faction> F in Factions)
     {
         //Debug.Log (F.ToString ());
         FactionHolder t = Instantiate(factionPrefab);
         t.name = F.Key;
         t.transform.SetParent(factionSpawn.transform);
         t.transform.localPosition = new Vector2(0.0f, 0.0f);
         F.Value.FactionPrefab     = t;
         t.isActive     = false;
         t.Flag.texture = F.Value.Flag;
         t.gameObject.SetActive(false);
         F.Value.FactionPrefab.GetComponent <FactionHolder> ().cCharacters.text = FactionManager.control.Factions [F.Value.Name].TotalOwnedChar.ToString();
     }
     if (GameControl.control.CurrentFaction == "US")
     {
         ShowUS();
     }
     else if (GameControl.control.CurrentFaction == "GERMANY")
     {
         ShowGERM();
     }
     else if (GameControl.control.CurrentFaction == "SOVIET")
     {
         ShowSOV();
     }
 }
Пример #3
0
    public void InitFromProjectileInfo(ProjectileInfo pi, GameObject parent, FactionHolder fh = null)
    {
        float deg = Mathf.Deg2Rad * parent.transform.rotation.eulerAngles.y;

        if (pi.AimTowardsTarget)
        {
        }
        else
        {
            transform.localPosition = transform.position + Orientation.OrientToVectorZ(pi.ProjectileCreatePos, deg);
        }
        AimPoint = Orientation.OrientToVectorZ(pi.ProjectileAimDirection, deg);

        ProjectileSpeed = pi.ProjectileSpeed;
        SetAimPoint(AimPoint);
        PenetrativePower = pi.PenetrativePower;
        Damage           = pi.Damage;
        Stun             = pi.Stun;
        Duration         = pi.HitboxDuration;
        AddElement(pi.Element);
        Knockback   = Orientation.OrientToVectorZ(pi.Knockback, deg);
        hitCallback = pi.hitCallback;
        if (fh != null)
        {
            fh.SetFaction(gameObject);
        }
        Creator = parent;
        Init();
    }
Пример #4
0
    public FactionHolder GetClosestOpposingFactionObj(FactionHolder go)
    {
        Vector3       pos         = go.gameObject.transform.position;
        float         minDistance = float.MaxValue;
        FactionHolder closest     = null;

        foreach (FactionType enemy in go.GetOpposingFactions())
        {
            if (!allFactionedObjects.ContainsKey(enemy))
            {
                continue;
            }
            foreach (FactionHolder fh in allFactionedObjects[enemy])
            {
                float d = Vector3.Distance(pos, fh.gameObject.transform.position);
                if (d < minDistance)
                {
                    minDistance = d;
                    closest     = fh;
                }
            }
        }
        if (go.Faction == FactionType.ALLIES)
        {
            //Debug.Log("New Closest: " + pos + " : " + closest.transform.position + " d: " + d + " o: " + fh.gameObject);
        }
        return(closest);
    }
Пример #5
0
    public Transform GetNearestEnemy(float MaxYDiff = -1f)
    {
        FactionHolder go = FindObjectOfType <FactionManager>().GetClosestOpposingFactionObj(this);

        if (go != null)
        {
            return(go.transform);
        }
        return(null);
    }
Пример #6
0
    public void DeregisterAttackable(FactionHolder go)
    {
        FactionType ft = go.Faction;

        if (!allFactionedObjects.ContainsKey(ft) || !allFactionedObjects[ft].Contains(go))
        {
            return;
        }
        allFactionedObjects[ft].Remove(go);
    }
Пример #7
0
    public void RegisterAttackable(FactionHolder go)
    {
        FactionType ft = go.Faction;

        if (!allFactionedObjects.ContainsKey(ft))
        {
            allFactionedObjects[ft] = new List <FactionHolder>();
        }

        allFactionedObjects[ft].Add(go);
    }
Пример #8
0
    public void InitFromHitboxInfo(HitboxInfo hbi, GameObject parent, FactionHolder fh = null)
    {
        if (hbi.FollowCharacter)
        {
            transform.SetParent(parent.transform);
            transform.localScale    = new Vector3(hbi.HitboxScale.x / transform.localScale.x, hbi.HitboxScale.y / transform.localScale.y, hbi.HitboxScale.z / transform.localScale.z);
            transform.localPosition = hbi.HitboxOffset;
            transform.localRotation = Quaternion.identity;
        }
        else
        {
            SetScale(hbi.HitboxScale);// : orient.OrientVectorToDirection2D(hbi.HitboxScale, false));
        }
        Damage       = hbi.Damage;
        OriginSource = hbi.OriginSource;

        FocusDamage = hbi.FocusDamage;
        Penetration = hbi.Penetration;
        Duration    = hbi.HitboxDuration;
        float deg = Mathf.Deg2Rad * parent.transform.rotation.eulerAngles.y;

        Knockback        = Orientation.OrientToVectorZ(hbi.Knockback, deg);// (orient == null) ? hbi.Knockback : orient.OrientVectorToDirection2D(hbi.Knockback);
        IsFixedKnockback = hbi.FixedKnockback;
        Stun             = hbi.Stun;
        FreezeTime       = hbi.FreezeTime;
        AddElement(hbi.Element);
        Creator     = parent;
        hitCallback = hbi.hitCallback;
        if (fh != null)
        {
            fh.SetFaction(gameObject);
        }
        IsResetKnockback = hbi.ResetKnockback;
        if (hbi.FollowCharacter)
        {
            SetFollow(parent, hbi.HitboxOffset);
        }
        hitCallback = hbi.hitCallback;
        if (hbi.MyNoiseType != NoiseType.NONE)
        {
            if (GetComponent <NoiseAI>() == null)
            {
                gameObject.AddComponent <NoiseAI>();
            }
            NoiseAI noise = GetComponent <NoiseAI>();
            noise.PlaySound(hbi.MyNoiseType, hbi.NoiseRange);
        }
        Init();
    }
Пример #9
0
 public bool CanAttack(FactionHolder f)
 {
     return(CanAttack(f.Faction));
 }
Пример #10
0
 // Start is called before the first frame update
 void Start()
 {
     m_factionHolder = GetComponent <FactionHolder>();
     m_toArmTime     = Time.timeSinceLevelLoad + MinimumArmTime;
 }