Example #1
0
    private void ProcessEntry(Collider2D collider2D, bool enter)
    {
        if (collider2D.gameObject.layer != Globals.BIPED_LAYER)
        {
            return;
        }

        if (enter)
        {
            Chamber.SetWeaponsActive(true);
            if (_hasBeenEntered && _allowOneEntry)
            {
                return;
            }

            Biped biped = collider2D.gameObject.GetComponent <Biped>();
            biped.Player.AddPoints(PointType.Chamber);

            AdvanceGeneration();
            _hasBeenEntered = true;
        }
        else if (collider2D.gameObject.activeSelf)
        {
            Chamber.SetWeaponsActive(false);
        }
    }
Example #2
0
    internal void TrySpawnBiped(Biped biped, Vector3 position)
    {
        if (AllBipedsSpawned)
        {
            return;
        }
        if (Physics2D.OverlapCircle(position, Globals.singleton.bipeds.bipedSpawnCheckRadius, ~Globals.singleton.bipeds.bipedSpawnCheckIgnoredLayers) != null)
        {
            return;
        }
        if (Time.time < _nextAllowBipedSpawnTime)
        {
            return;
        }
        _nextAllowBipedSpawnTime = Time.time + Globals.singleton.bipeds.bipedSpawnNextDelay;

        CreateBiped(biped, position);

        if (AllBipedsSpawned)
        {
            _controller.AllowMovement = true;

            TrySetCameraTarget();
            UIEventDelegate.Invoke(SandboxEvent.AllBipedsSpawned);
        }
    }
	/*
	 * Try to find a character naming prefix for a Biped specified as using 3DS Max Biped naming conventions
	 * */
	public static string FindCharacterNamePrefixOnMaxBiped(Biped biped)
	{
		Component[] hierarchy = biped.GetComponentsInChildren<Transform>();
		foreach (Component c in hierarchy)
			if (c.name.EndsWith("Pelvis"))
				return c.name.Substring(0, c.name.LastIndexOf("Pelvis"));
		return "";
	}
Example #4
0
 private void OnTriggerEnter2D(Collider2D collider2D)
 {
     if (collider2D.gameObject.layer == Globals.BIPED_LAYER)
     {
         Biped biped = collider2D.gameObject.GetComponent <Biped>();
         biped.Die();
     }
 }
Example #5
0
 // Start is called before the first frame update
 void Start()
 {
     player         = GameObject.FindWithTag("Player");
     animator       = gameObject.GetComponent <Animator>();
     bipedComponent = gameObject.GetComponent <Biped>();
     if (player)
     {
         distance = Vector3.Distance(player.transform.position, transform.position);
     }
 }
Example #6
0
    private void CreateBiped(Biped biped, Vector3 position)
    {
        GameObject newBipedGameObject = Instantiate(biped.gameObject, position, Quaternion.identity, Globals.singleton.containers.bipeds);
        Biped      newBiped           = newBipedGameObject.GetComponent <Biped>();

        _bipeds.Add(newBiped);
        newBiped.SetAspects(this);
        newBiped.SetDesign(_profile.bipedDesigns[_bipeds.Count - 1]);
        OutputBipedCounts();
    }
Example #7
0
 private bool TryAffectBiped(Collision2D collision2D)
 {
     if (collision2D.gameObject.layer == Globals.BIPED_LAYER)
     {
         Biped biped = collision2D.gameObject.GetComponent <Biped>();
         biped.Die();
         return(false);
     }
     return(true);
 }
 /*
  * Try to find a character naming prefix for a Biped specified as using 3DS Max Biped naming conventions
  * */
 public static string FindCharacterNamePrefixOnMaxBiped(Biped biped)
 {
     Component[] hierarchy = biped.GetComponentsInChildren <Transform>();
     foreach (Component c in hierarchy)
     {
         if (c.name.EndsWith("Pelvis"))
         {
             return(c.name.Substring(0, c.name.LastIndexOf("Pelvis")));
         }
     }
     return("");
 }
        private void LoadBipedPreview(TagFileName tfn)
        {
            TagBase tagdata = new TagBase();

            tagdata.LoadTagBuffer(tfn);
            BinaryReader br = new BinaryReader(tagdata.Stream);

            Biped obj = new Biped();

            obj.Read(br);
            obj.ReadChildData(br);
            LoadModelTag(new TagFileName(obj.ObjectValues.Model.Value, "mod2", tfn.Version));
            LoadAnimationTag(new TagFileName(obj.ObjectValues.AnimationGraph.Value, "antr", tfn.Version));
        }
Example #10
0
    internal bool TryPickupAllBipeds(PickupType pickupType, Biped biped)
    {
        if (!AllBipedsSpawned)
        {
            return(false);
        }

        if (pickupType != PickupType.Coin)
        {
            if (_nextAllowPickup > Time.time)
            {
                return(false);
            }
            _nextAllowPickup = Time.time + Globals.singleton.bipeds.nextPowerupPickupDelay;
            AddPoints(PointType.Powerup);
        }

        switch (pickupType)
        {
        case PickupType.Nitro:
            _uISignal.Invoke(SandboxEvent.Nitro);
            break;

        case PickupType.Normous:
            _uISignal.Invoke(SandboxEvent.Normous);
            break;

        case PickupType.Normal:
            _uISignal.Invoke(SandboxEvent.Normal);
            break;

        case PickupType.New:
            TryRespawnNinjas(Globals.singleton.bipeds.newPowerupBipedCount, biped);
            _uISignal.Invoke(SandboxEvent.New);
            break;

        case PickupType.Coin:
            _profile.Coins += 1;
            GameManager.singleton.SaveProfile();
            break;

        default:
            break;
        }
        foreach (Biped existingBiped in _bipeds)
        {
            existingBiped.Powerup(pickupType);
        }
        return(true);
    }
Example #11
0
    internal void BipedDied(Biped biped)
    {
        _deadBipedCount++;
        _cameraController.StartShake();
        OutputBipedCounts();

        if (AllBipedsSpawned)
        {
            TrySetCameraTarget();
            if (ActiveBipedCount == 0)
            {
                AllBipedsDead();
            }
        }
    }
Example #12
0
        public void initControl(SkinModelSkelAnim skinAniModel)
        {
            m_radar   = new Radar();
            m_vehicle = new Biped();

            //m_vehicle.Radar = m_radar;
            //m_vehicle.ArrivalRadius = 1;
            //m_vehicle.AllowedMovementAxes = new Vector3(1, 0, 1);
            //m_vehicle.MaxSpeed = 10;
            //m_vehicle.setSpeed(5);
            //m_vehicle.initOwner(skinAniModel.rootGo);

            //m_radar.Vehicle = m_vehicle;
            //m_radar.initAwake();
            m_radar.DetectionRadius = 100;
        }
Example #13
0
    private bool TryApply(Biped biped)
    {
        // Attempt to apply the powerup to all bipeds.
        bool applied = biped.Player.TryPickupAllBipeds(_pickupType, biped);

        if (!applied)
        {
            return(false);
        }

        // If we applied the powerup, update our chamber manager which uses this to determine powerup spawns.
        if (ChamberManager.singleton != null)
        {
            ChamberManager.singleton.CurrentPickup = _pickupType;
        }
        return(true);
    }
Example #14
0
    private void TryRespawnNinjas(int count, Biped biped)
    {
        int spawnedCount = 0;

        foreach (Biped existingBiped in _bipeds)
        {
            if (!existingBiped.gameObject.activeSelf)
            {
                existingBiped.Respawn(biped.transform.position, biped.transform.rotation);
                spawnedCount++;
                if (spawnedCount == count)
                {
                    break;
                }
            }
        }
        OutputBipedCounts();
    }
Example #15
0
    private void ProcessEntry(Collider2D collider2D)
    {
        if (collider2D.gameObject.layer != Globals.BIPED_LAYER)
        {
            return;
        }
        if (!_spriteRenderer.isVisible)
        {
            return;
        }

        Biped biped   = collider2D.gameObject.GetComponent <Biped>();
        bool  applied = TryApply(biped);

        if (applied)
        {
            Destroy(this.gameObject);
        }
    }
Example #16
0
    /// <summary>
    /// Updates grounded status for this biped and any biped it may rely on (if this biped rests on another)
    /// </summary>
    internal void UpdateGrounding()
    {
        // If the biped is dead, stop.
        if (Dead)
        {
            return;
        }

        // Check that we haven't updated in this cycle already and update state and continue if we haven't.
        if (_groundingCheckedTime == Globals.singleton.PhysicsUpdateCount)
        {
            return;
        }
        else
        {
            _groundingCheckedTime = Globals.singleton.PhysicsUpdateCount;
        }

        // Check all of our collisions to verify we are grounded.
        bool grounded             = false;
        bool adoptedGrounded      = false;
        bool adoptedGroundedValue = false;

        Collision2D[] collisions = new Collision2D[_collisionList.Collisions2D.Values.Count];
        _collisionList.Collisions2D.Values.CopyTo(collisions, 0);
        foreach (Collision2D collision2D in collisions)
        {
            for (int i = 0; i < collision2D.contacts.Length; i++)
            {
                float angle          = Vector3.Angle(this.transform.up, collision2D.contacts[i].normal);
                float yContactOffset = Vector2.Dot(this.transform.up, (collision2D.contacts[i].point - (Vector2)this.transform.position));
                bool  groundedAngle  = angle <= _maxGroundAngle && yContactOffset < 0;

                // Check the type of collision.
                if (collision2D.gameObject.layer == Globals.MACHINE_LAYER)
                {
                    // If it's a machine, obtain the surface component.
                    Surface surface = collision2D.gameObject.GetComponent <Surface>();
                    if (surface != null)
                    {
                        // Kill the biped if this surface is a kill impactor, and stop since we're done processing.
                        if (surface.KillImpactor)
                        {
                            Die();
                            return;
                        }

                        // Apply bounce velocity if this surface bounces and we're grounded on this angle.
                        // TODO: Revisit this to allow for instantaneous velocity bounce.
                        if (groundedAngle && surface.HasBounce)
                        {
                            _bounceVelocity = surface.Bounciness;
                        }
                    }

                    // If this is an appropriate angle, the player should be grounded.
                    grounded |= groundedAngle;
                }
                else if (collision2D.gameObject.layer == Globals.BIPED_LAYER)
                {
                    // If it's a biped, obtain the Biped component.
                    Biped biped = collision2D.gameObject.GetComponent <Biped>();

                    if (groundedAngle && biped._bounceVelocity > _bounceVelocity)
                    {
                        _bounceVelocity = biped._bounceVelocity;
                    }
                    if (groundedAngle && biped._jumpVelocity > _jumpVelocity)
                    {
                        _jumpVelocity = biped._jumpVelocity;
                    }

                    // Check the biped is ontop.
                    if (groundedAngle)
                    {
                        // If it is, we update our lower ninjas state and determine our state based off of this.
                        biped.UpdateGrounding();

                        // If the lower ninja isn't grounded and we're on it, we adopt it's state.
                        adoptedGroundedValue = biped._grounded;
                        adoptedGrounded      = true;
                    }
                }
                else
                {
                    // If this is an appropriate angle, the player should be grounded.
                    grounded |= groundedAngle;
                }
            }
        }

        // If we adopted grounded status from a biped, set it accordingly.
        if (adoptedGrounded)
        {
            grounded = adoptedGroundedValue;
        }

        // If we're grounded and have no jump or bounce velocity, set our velocity as 0.
        if (grounded && _jumpVelocity == 0 && _bounceVelocity == 0)
        {
            Vector2 relativeVelocity = RelativeVelocity;
            relativeVelocity.y = 0;
            RelativeVelocity   = relativeVelocity;
        }

        // Update our grounded state
        _grounded = grounded;
    }
Example #17
0
 public static void Populate(CommandContext commandContext, GameCache cache, CachedTag tag, Biped biped)
 {
 }
Example #18
0
        public static CommandContext Create(CommandContext parent, GameCache cache, CachedTag tag, Biped biped)
        {
            var groupName      = cache.StringTable.GetString(tag.Group.Name);
            var commandContext = new CommandContext(parent, string.Format("{0:X8}.{1}", tag.Index, groupName));

            Populate(commandContext, cache, tag, biped);

            return(commandContext);
        }
Example #19
0
 /*
  * Initialize
  * */
 void OnEnable()
 {
     biped = (Biped)target;
 }
Example #20
0
 public static void Populate(CommandContext commandContext, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, Biped biped)
 {
 }
Example #21
0
        public static CommandContext Create(CommandContext parent, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, Biped biped)
        {
            var groupName      = cacheContext.GetString(tag.Group.Name);
            var commandContext = new CommandContext(parent, string.Format("{0:X8}.{1}", tag.Index, groupName));

            Populate(commandContext, cacheContext, tag, biped);

            return(commandContext);
        }
	/*
	 * Initialize
	 * */
	void OnEnable()
	{
		biped = (Biped) target;
	}